Function round_robin_tournament::round_robin_tournament::draw[][src]

pub fn draw(number_of_players: u32) -> Vec<Vec<(u32, u32)>>

Implementation of the round robin tournament algorithm.

For a given number_of_players it return the pairs and rounds. For an odd number of players, the algorithm calculates with number_of_players + 1. So you have to make sure that the player who plays against the highest number has a bye.

Example

use round_robin_tournament::round_robin_tournament::draw;
let tournament: Vec<Vec<(u32, u32)>> = draw(10);
/*
[(0, 9), (1, 8), (2, 7), (3, 6), (4, 5)]
[(1, 9), (2, 0), (3, 8), (4, 7), (5, 6)]
[(2, 9), (3, 1), (4, 0), (5, 8), (6, 7)]
[(3, 9), (4, 2), (5, 1), (6, 0), (7, 8)]
[(4, 9), (5, 3), (6, 2), (7, 1), (8, 0)]
[(5, 9), (6, 4), (7, 3), (8, 2), (0, 1)]
[(6, 9), (7, 5), (8, 4), (0, 3), (1, 2)]
[(7, 9), (8, 6), (0, 5), (1, 4), (2, 3)]
[(8, 9), (0, 7), (1, 6), (2, 5), (3, 4)]
*/