Tournaments!
Tournaments are coming!
This will be one of the biggest changes to the ButtonWeavers site that we've ever made in one hit. The initial commit, which only includes very basic functionality (rudimentary UI, single elimination tournaments), requires changes to 22 files and the addition of 44 files. It involves roughly 5000 new lines of code, including 3 all new UI pages.
The backend design of tournaments is intended to meet future requirements easily, including
My hope is that tournaments will help people to get connected with others on the site more easily. I am looking forward to stumbling across new players who I may have otherwise not noticed, as well as reconnecting with players who I've lost contact with.
Each tournament type has a single file that specifies it, similar to BMTournamentSingleElimination.php. This file contains the logic to:
(i) create the games for each round
(ii) update who is still in the tournament after each round
(iii) check whether the tournament has completed.
For example, for the single elimination tournament, these look like this:
(i) Take pairs of players from those remaining in the tournament, create games between them using the first (and only) button that they have selected for this tournament, and add the game numbers to the tournament.
(ii) At the end of the round, all players who lost their game (or were forced to forfeit) in that round are removed from the list of remaining players.
(iii) The tournament is complete if there is one player remaining.
The changes to BMGame and BMInterface are minimal, basically just allowing a tournament ID and round number to be associated with a game. It may be necessary in the future when a game ends to trigger an update_state() for the tournament, but that's not in there at the moment.
The changes to BMInterfaceGame are mostly to allow games to be created by behind-the-scenes code.
BMTournamentState is the analogue of BMGameState customised for tournaments.
BMTournament does all the heavy lifting. Its structure is modelled upon BMGame. For anyone familiar with BMGame, the main iterative steps will look very familiar: do_next_step() and update_tournament_state(), which are run inside proceed_to_next_user_action(). The logic moves the tournament through the tournament states specified in BMTournamentState:
The abstract functions are the ones that need to be customised in different tournament types, as described in the previous post.
BMInterfaceTournament supports the creation and updating of the database state of tournaments.
This will be one of the biggest changes to the ButtonWeavers site that we've ever made in one hit. The initial commit, which only includes very basic functionality (rudimentary UI, single elimination tournaments), requires changes to 22 files and the addition of 44 files. It involves roughly 5000 new lines of code, including 3 all new UI pages.
The backend design of tournaments is intended to meet future requirements easily, including
- new tournament types
- button restriction
- better display of tournaments, tailored to each tournament type
- the ability to force the tournament to advance past idle games (no more bonefishing!)
- automatic site generation of daily tournaments
My hope is that tournaments will help people to get connected with others on the site more easily. I am looking forward to stumbling across new players who I may have otherwise not noticed, as well as reconnecting with players who I've lost contact with.
For those who are interested, details of the backend implementation follow, with text adapted from Issue 2131.
Each tournament type has a single file that specifies it, similar to BMTournamentSingleElimination.php. This file contains the logic to:
(i) create the games for each round
(ii) update who is still in the tournament after each round
(iii) check whether the tournament has completed.
For example, for the single elimination tournament, these look like this:
(i) Take pairs of players from those remaining in the tournament, create games between them using the first (and only) button that they have selected for this tournament, and add the game numbers to the tournament.
(ii) At the end of the round, all players who lost their game (or were forced to forfeit) in that round are removed from the list of remaining players.
(iii) The tournament is complete if there is one player remaining.
The changes to BMInterfaceGame are mostly to allow games to be created by behind-the-scenes code.
BMTournamentState is the analogue of BMGameState customised for tournaments.
BMTournament does all the heavy lifting. Its structure is modelled upon BMGame. For anyone familiar with BMGame, the main iterative steps will look very familiar: do_next_step() and update_tournament_state(), which are run inside proceed_to_next_user_action(). The logic moves the tournament through the tournament states specified in BMTournamentState:
- START_TOURNAMENT
- JOIN_TOURNAMENT
- SHUFFLE_PLAYERS
- START_ROUND
- PLAY_GAMES
- END_ROUND
- END_TOURNAMENT
- (CANCELLED)
The abstract functions are the ones that need to be customised in different tournament types, as described in the previous post.
BMInterfaceTournament supports the creation and updating of the database state of tournaments.
Comments
Post a Comment