Simple Bracket Generator
- PHP 7.4+
- Create new instance of the Bracket Generator:
$generator = new \BracketGenerator\Generator();
- Use the
generate
method to get array with bracket games. You need to pass the number of tournament participants:
$generator->generate(8);
- You should get an array of games:
[
[
'id' => 1,
'round' => 1,
'game_in_round' => 1,
'next_game_id' => 5
],
[
'id' => 2,
'round' => 1,
'game_in_round' => 2,
'next_game_id' => 5
],
[
'id' => 3,
'round' => 1,
'game_in_round' => 3,
'next_game_id' => 6
],
[
'id' => 4,
'round' => 1,
'game_in_round' => 4,
'next_game_id' => 6
],
[
'id' => 5,
'round' => 2,
'game_in_round' => 1,
'next_game_id' => 7
],
[
'id' => 6,
'round' => 2,
'game_in_round' => 2,
'next_game_id' => 7
],
[
'id' => 7,
'round' => 3,
'game_in_round' => 1,
'next_game_id' => null
],
];
For now, the library is able to generate only a single elimination bracket. Feel free to contribute. Thanks!