crates.io Documentation Workflow License License: MIT

Social Tournament

This is a library for creating tournament schedules for the sport I love.

🏓 table tennis 🏓

The focus is on meeting as many opponents and teammates as possible during the tournament. One can draw a single or double tournament.

Example

Get rounds for a single tournament (round robin) ```rust use socialtournament::model::RoundSingles; use socialtournament::single::draw_singles;

let tournament: Vec = draw_singles(10,9); /* Creates: Round number: 0 SingleMatch { a: 0, b: 9 } SingleMatch { a: 1, b: 8 } SingleMatch { a: 2, b: 7 } SingleMatch { a: 3, b: 6 }

SingleMatch { a: 4, b: 5 }

Round number: 1 SingleMatch { a: 1, b: 9 } SingleMatch { a: 2, b: 0 } SingleMatch { a: 3, b: 8 } SingleMatch { a: 4, b: 7 }

SingleMatch { a: 5, b: 6 }

... */ ```

If you want to get rounds for a double tournament you have to do the following: ```rust use socialtournament::model::RoundDoubles; use socialtournament::double::{draw_doubles, DrawOption};

let tournament: Vec = drawdoubles(39, 12, Some(DrawOption::ForceDoubleOnly)); /* Creates: Round number: 0 DoubleMatch { doublea: (2, 37), doubleb: (1, 38) } DoubleMatch { doublea: (3, 36), doubleb: (4, 35) } DoubleMatch { doublea: (5, 34), doubleb: (6, 33) } DoubleMatch { doublea: (7, 32), doubleb: (8, 31) } DoubleMatch { doublea: (9, 30), doubleb: (10, 29) } DoubleMatch { doublea: (11, 28), doubleb: (12, 27) } DoubleMatch { doublea: (13, 26), doubleb: (14, 25) } DoubleMatch { doublea: (15, 24), double_b: (16, 23) }

DoubleMatch { doublea: (17, 22), doubleb: (18, 21) }

Round number: 1 DoubleMatch { doublea: (2, 37), doubleb: (1, 38) } DoubleMatch { doublea: (3, 36), doubleb: (4, 35) } DoubleMatch { doublea: (5, 34), doubleb: (6, 33) } DoubleMatch { doublea: (7, 32), doubleb: (8, 31) } DoubleMatch { doublea: (9, 30), doubleb: (10, 29) } DoubleMatch { doublea: (11, 28), doubleb: (12, 27) } DoubleMatch { doublea: (13, 26), doubleb: (14, 25) } DoubleMatch { doublea: (15, 24), doubleb: (16, 23) }

DoubleMatch { doublea: (17, 22), doubleb: (18, 21) }

... */ ```

Double Options

For number of players that are not completely divisible by 4 you can choose between three DrawOption. Depending on the selected option you can have doubles with only 3 players, single matches or player with byes. You have to make sure that the player ids >= number_of_players in the schedule post processed correctly. So that you can mark them as byes for example.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.