This project provides a way to play your favorite turn-based board games online via a Client-Server architecture. You can also choose how to play the game: by inputting your own choices, having a move randomly chosen, or using an implementation of the Monte-Carlo Tree Search algorithm. Other Client-Server functionalities are also supported, such as having a global group chat, private messaging, and more!
The purpose of this project is to showcase the value of highly clean, maintainable code. A great level of care and detail was invested to ensure that future extensions to this project (e.g. new board games variants) can be integrated into the existing project seamlessly and require a very minimal amount of new code to be written. Not only that, but it should be extremely clear from the existing code and javadoc how to implement those future extensions.
The following steps will instruct you on how to get a local version of this project working in no time; whether to play a game or develop your own.
The following software must be installed to follow the installation steps:
- Git - How to install Git
- Java 23 (or higher) - How to install Java 23
- Apache Maven - two options:
- Install Apache Maven to be used throughout your machine - How to install Apache Maven
- Use an IDE, such as IntelliJ, and use the Apache Maven plugin - How to use Apache Maven in IntelliJ
-
Start by copying this repository into a local folder:
git clone github.com/alias012/board-games -
Enter the new
board-gamesdirectory:cd board-games -
If you want to make changes to the source code and/or package the code locally, run the following Apache Maven goals (otherwise skip this step):
mvn clean compile package -
Now enter the (newly) generated
targetdirectory:cd target -
The following jar files should all be found inside:
RunServer.jarRunClient.jarboard_games-1.0.0.jarboard_games-1.0.0-javadoc.jarboard_games-1.0.0-test.jar
-
Follow the How To Use section and enjoy!
n.b. You can also import the jar files starting with board_games- as an external library into
another project
The expected "happy path" will be demonstrated below:
-
Open a new terminal and run the Server:
java -jar RunServer.jar -
Enter the type of server you would like to run (e.g. QUARTO):
QUARTO Please input one of the options: QUARTO -
Enter the port number to listen on (e.g. 12345):
Input the port number to connect to: 12345 -
Open two new terminals and run a Client in each:
java -jar RunClient.jar -
Enter the type of client you would like to run (e.g. 'QUARTO' for the first, 'AUTOPLAY_QUARTO' for the second)
QUARTO, AUTOPLAY_QUARTO Please input one of the options: QUARTO -
Enter the IP address to connect to (right now the server is running locally, so just hit enter/return)
Input the IP address to connect to (leave blank for localhost): -
Enter the port number to connect to (right now the server is listening on port 12345, so enter that)
Input the port number to connect to: 12345 -
For the AUTOPLAY_QUARTO client, now input your username (e.g. 'autoplay')
Successfully connected to server Input your desired username: autoplay -
Still for the AUTOPLAY_QUARTO client, now input the strategy you want to employ (e.g. 'RANDOM')
HUMAN, RANDOM, MCTS Please input one of the options: RANDOM -
And finally, still for the AUTOPLAY_QUARTO client, now input the queue to join (e.g. 'abc')
Enter the name of the queue to repeatedly join: abc -
The AUTOPLAY_QUARTO client is all set up, and you do not need to do anything else for it!
-
Going back to the QUARTO client, you should have a list of options:
Successfully connected to server Enter: LOGIN, LIST, QUEUE, MOVE, EXIT [Extras: QUEUE with name, RANK, CHAT, WHISPER] -
An explanation of the options them follows:
LOGIN: attempts to log in to the server with a usernameLIST: lists all active clients on the serverQUEUE: queues you up and will put you in a game with others in the same queueMOVE: play a move for the game you are playingEXIT: disconnect from the server and quit the programRANK: get the number of wins of all users (active and inactive) on the serverCHAT: send a chat message to all active clientsWHISPER: send a private message to a specific client
-
Now, enter 'LOGIN' and enter your username (e.g. 'quarto'):
LOGIN Input your desired username: quarto Successfully logged in -
Next, enter 'QUEUE', choose a strategy (e.g. 'HUMAN') and the queue to join ('abc', so that we queue against the AUTOPLAY client):
queue HUMAN, RANDOM, MCTS Please input one of the options: HUMAN Enter the name of the queue to join: abc A new Quarto game has started! You are versus autoplay Your opponent has the first turn. A new move has been made! X_X_X_X is the next piece to be played | | | 00 | 01 | 02 | 03 ----+----+----+---- ----+----+----+---- | | | 04 | 05 | 06 | 07 ----+----+----+---- ----+----+----+---- | | | 08 | 09 | 10 | 11 ----+----+----+---- ----+----+----+---- | | | 12 | 13 | 14 | 15 -
Finally, enter
MOVEand choose what index to play the piece (e.g. '5'), and the number of the next piece to play (e.g. '1'):move Enter the index to play the next piece: 5 Remaining pieces: 1: LSRS, 2: DSRS, 3: DLRS, 4: LSSS, 5: DSSS, 6: LLSS, 7: DLSS, 8: LSRH, 9: DSRH, 10: LLRS, 11: DLRH, 12: LSSH, 13: DSSH, 14: LLSH, 15: DLSH, 16: QUARTO, Opponent's next piece: 1 A new move has been made! New move at index 5 LIGHT_SMALL_ROUND_SOLID is the next piece to be played | | | 00 | 01 | 02 | 03 ----+----+----+---- ----+----+----+---- |LLRS| | 04 | 05 | 06 | 07 ----+----+----+---- ----+----+----+---- | | | 08 | 09 | 10 | 11 ----+----+----+---- ----+----+----+---- | | | 12 | 13 | 14 | 15 -
You are now well-equipped to use the server and the client. Have fun!
Contributing to this project is not desired at this time, but if you desire to do so, start by making an issue on this repository describing the contribution you have in mind.
SemVer is used for versioning. Due to the very low-coupling in the project, adding new board game variants should not qualify as a MAJOR change.
This project is licensed under the MIT License - see the LICENSE.md file for details.
Java, Maven, JUnit, Client-Server Architecture, Monte Carlo Tree-Search, Clean Code, Maintainable Code, Documentation, Low Coupling, High Cohesion, Defensive Programming, Absolutely 0% AI Generated.