Computer Networks Laboratory Project – Spring 2025
- Online multiplayer – two remote players matched automatically over TCP
- AWS-hosted server – lightweight, headless, thread-pooled
- Modern Swing GUI – FlatLaf skin, custom dice widgets & animated lobby
- Rule-complete Yahtzee logic – upper-section bonus, Yahtzee bonuses, time-outs, concede
- Replay without restart – return to lobby and start a new match instantly
Both clients open a persistent TCP socket to the public AWS server.
Each pair of sockets is handled by one GameSession
running inside the server’s thread pool.
└── zahidesad-yahtzeegame/
├── README.md
├── LICENSE
├── pom.xml
└── src/
└── main/
├── java/
│ ├── server/
│ │ ├── GameSession.java
│ │ ├── PlayerHandler.java
│ │ └── YahtzeeServer.java
│ └── yahtzee/
│ ├── YahtzeeFrame.java
│ ├── controller/
│ │ └── GameController.java
│ ├── model/
│ │ ├── Dice.java
│ │ ├── Game.java
│ │ ├── Player.java
│ │ ├── ScoreCard.java
│ │ ├── ScoreEntry.java
│ │ └── Categories/
│ │ ├── Bonus.java
│ │ ├── Category.java
│ │ ├── Chance.java
│ │ ├── FourOfAKind.java
│ │ ├── FullHouse.java
│ │ ├── LargeStraight.java
│ │ ├── SmallStraight.java
│ │ ├── ThreeOfAKind.java
│ │ ├── Total.java
│ │ ├── UpperCategory.java
│ │ └── Yahtzee.java
│ ├── network/
│ │ ├── Message.java
│ │ ├── MessageType.java
│ │ └── NetworkClient.java
│ └── view/
│ ├── GamePanel.java
│ ├── LobbyPanel.java
│ ├── Resettable.java
│ ├── ScoreBoard.java
│ ├── ScoreGroup.java
│ ├── StaticScoreGroup.java
│ └── YahtzeeDice.java
└── resources/
└── yahtzee/
└── images/
- JDK 21 (tested with Amazon Corretto 21)
- Maven 3.9+
- (Optional) an AWS EC2 instance for server deployment
# clone
git clone https://github.com/<username>/zahidesad-yahtzeegame.git
cd zahidesad-yahtzeegame
# package fat-jar
mvn clean package
# start server (local test)
java -cp target/YahtzeeGame-*-jar-with-dependencies.jar server.YahtzeeServer
# start client (each player runs one instance)
java -cp target/YahtzeeGame-*-jar-with-dependencies.jar yahtzee.YahtzeeFrame
The default client connects to localhost
; edit
yahtzee/view/LobbyPanel.java → SERVER_IP
or type the public IP at runtime.
-
Launch an Ubuntu 22.04 t3.micro instance.
-
Open TCP port 12345 in the security group.
-
Copy the fat-jar to /home/ubuntu/yahtzee/.
-
Add a simple systemd unit (sample below) and enable it.
# /etc/systemd/system/yahtzee.service
[Unit]
Description=Yahtzee Game Server
After=network.target
[Service]
WorkingDirectory=/home/ubuntu/yahtzee
ExecStart=/usr/bin/java -jar YahtzeeGame-*-jar-with-dependencies.jar
Restart=always
User=ubuntu
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now yahtzee
journalctl -u yahtzee -f # follow logs
Clients now connect to the instance’s public IPv4.
This project is licensed under the Apache License 2.0
FlatLaf – modern open-source Look-and-Feel for Swing
Gson – JSON parsing and serialisation
Enjoy playing Yahtzee online!