A simple distributed multiplayer sudoku game in the terminal, implemented in Python using RPC.
From the root directory, run python2.7 server/serverMain.py
.
An optional -a
flag followed by the server IP address can be specified. By default, the server listens to 127.0.0.1
.
From the root directory, run python2.7 client/clientMain.py
.
Clients guide players through the setup process of the game. Players go through the setup to:
- Pick asked for a (unique) nickname.
- Enter the IP address of the server they want to play on.
- Choose an option based on the server:
- Create a new session, specify the number of players in the game, and wait for others to join the session.
- Join an existing session by specifying the name of the session.
When all the players in a given session connect, the game starts by displaying an identical sudoku grid to all players. The number of unfilled spaces is predetermined statically in code via the LEVEL
variable in sudoku_new_py
.
Players try to fill in the spaces on the grid by solving the sudoku. Players will gain a point for a correct guess, lost one for an incorrect guess, and be prompted to try again if they’ve tried to place a number in a filled spot.
There are several ways the server decides to end the game:
- The default and the natural way for the game to end is when all the grid spaces are filled.
- Since there is a minimum number of players required per session, the game ends when less than two players are left in the game due to, say, a disconnect.
When the game ends, all the players remaining are notified of the winner and are retuned to the lobby.
- Responsible for asking players for input during setup and gameplay.
- Communicates with the server.
- Provices I/O capabilities for the player from the terminal.
- Facilitated by classes such as
SyncConsoleAppenderRawInputReader
andAbstractSyncIO
.
- Responsible for creating a listener socket.
- Keeps track of connected clients and game sessions.
- Creates
clientHandler
objects to process client requests.
- Processes client requests, and sends notifications to clients.
- Allows
clientHander
objects to interact with sudoku instances. - Keeps track of and notifies clients of changes to the game status.
- Creates, validates, and makes changes to sudoku grids.
- Numbers are added spots via instances of the member class.
- Helps determine if a given grid arrangement ends the game.