Coordinate and track results for Swiss-style game tournaments using Python 2 and a PostgreSQL database.
Log into your web server via SSH and be sure to have Python 2 and PostgreSQL installed.
To initialize the required tables, run:
$ psql
$ \i tournament.sql
To run a suite of unit tests, quit PostgreSQL with \q
and then:
$ python tournament_test.py
PLAYERS
Includes the player's name and ID number.
MATCHES
ALL match results are recorded here with a match ID numer and the resulting winner or loser.
VIEW_WINS (view)
Keeps track of the number of wins for each player.
VIEW_LOSSES (view)
Keeps track of the number of losses for each player.
VIEW_MATCHES (view)
Keeps track of the count of matches each player has played.
Use the available Python functions, in this recommended order, to coordinate a game:
METHOD | ACCEPTS | PURPOSE |
---|---|---|
registerPlayer(name) | name as string | Adds a player to the database to be calculated in pairings and standings. |
countPlayers() | (no input) | Counts all registered players. |
swissPairings() | (no input) | Returns a list of players grouped into pairs, arranged according to their current standings. Players are paired with those with about the same number of wins. |
reportMatch(winner, loser) | winner as string, loser as string | Records the result of any given match. |
playerStandings() | (no input) | Returns the number of wins from all players. |