This repository includes the source code for Game of Three client and server.
- Make sure that openjdk version version is at least 11.0
- Make sure that make is installed
make is used to orchestrate most development tasks.
Command | Description |
---|---|
make build-server |
build server |
make start-server |
start game server |
make build-client |
build game client |
make start-client-manual |
start game client on manual mode |
make start-client-automatic |
start game client on automatic mode |
obs1.: you might need root access to run build at the first time so the wrapper can write on the file system. e.g. sudo make build-server
sudo make build-client
obs2.: the make
build commands will run the gradlew wrapper with a shell command. for windows you need to go inside server
and client
folder and run gradlew.bat build
When a player starts, it incepts a random (whole) number and sends it to the second player as an approach of starting the game. The receiving player can now always choose between adding one of {-1, 0, 1} to get to a number that is divisible by 3. Divide it by three. The resulting whole number is then sent back to the original sender. The same rules are applied until one player reaches the number 1(after the division).
For each "move", a sufficient output should get generated (mandatory: the added, and the resulting number). Both players should be able to play automatically without user input. The type of input (manual, automatic) should be optionally adjustable by the player.
The client and server communicates trough a single websocket endpoint ws://localhost:8080/game
and the players data is store in the server runtime memory for simplicity.
Objects are used for the web socket API:
ServerMessage
(message sent from server to client)ClientMessage
(message sent from client to server)Move
(a move with information about the turn)
text
Simple message text- type:
string
, optional
- type:
messageType
Type of the message- type:
enum
,MOVE
orINFO
orGAME_START
orGAME_OVER
orGAME_WIN
orOPPONENT_DISCONNECTED
, required
- type:
move
Current move / Opponent move- type:
move
, optional
- type:
example:
{
"text": "current move",
"messageType": "MOVE",
"move": {
"resultingNumber": 56,
"addedNumber": 0
}
}
move
Current move / Opponent move- type:
move
, required
- type:
example:
{
"move": {
"resultingNumber": 56,
"addedNumber": 0
}
}
resultingNumber
Resulting number- type:
integer
, required
- type:
addedNumber
Added Number- type:
integer
, required
- type:
example:
"move": {
"resultingNumber": 56,
"addedNumber": 0
}