This project implements a Tic Tac Toe game with a client-server architecture using Java and Spring Boot. The game allows two players to play against each other by connecting to a server. The game logic, synchronization, and logging are managed by the server, while the clients handle player moves and interactions with the server.
- Both players register with the server.
- Players take turns to make moves.
- The server validates each move and updates the game state.
- The game continues until a player wins or the game ends in a draw.
- Once the game is over, both players acknowledge the game over to the server.
- The server shuts down automatically after both players acknowledge the game over.
Logging is implemented to track the flow of the game and debug issues. The logs include:
- Player registration information.
- Moves made by players.
- Game status updates.
- Acknowledgments from players when the game is over.
- Server shutdown information.
Logs for the server and clients are displayed in the respective terminal windows. They provide detailed information about the game flow and any issues that may occur.
-
Navigate to the
server
directory. -
Run the following command to start the server:
mvn spring-boot:run
The server will start on port 8080.
-
Navigate to the
client
directory. -
Run the following command to start the first client:
java -jar target/client-0.0.1-SNAPSHOT.jar --server.port=8081
-
In a separate terminal, run the following command to start the second client:
java -jar target/client-0.0.1-SNAPSHOT.jar --server.port=8082
The clients will connect to the server and start playing the game automatically.
- The server shuts down automatically 5 seconds after both clients acknowledge the game over.
- Each client shuts down automatically after acknowledging the game over to the server.