Parallel Troopers

screenshot of parallel troopers screenshot of parallel troopers

 

Description:

Parallel Troopers was made as an exercise for the parallel and distributed systems course, which was part of my bachelor in Computer Science. It was made by a group of four students and took three weeks to complete.

The game is a realtime variant of Risk. Players get new armies each second in a country of their choice. To ease this process the player can right-click on a country to place his token in it. Each second the country that contains the token will then receive armies based on the number of countries and continents that the player posesses. Players can attack other players by first clicking on the country to attack from, and then clicking on the country to attack. Armies can also be moved from one country to another, by first clicking on the source country and then clicking on the target country. Moving armies always moves half the armies of the source country.

If a player manages to conquer a whole continent all lands in that continent will get bonus armies each second in addition to the armies that are added to the land with the token. The player that manages to conquer the whole world wins.

The realtime aspect of the game makes sure that the gameplay is fast and frantic. Players will try to click as fast as possible and the situation can change every second.


Challenges:

The biggest challenge of Parallel Troopers was the communication between the different players. The game is designed as a peer-to-peer application. To ensure that all clients stay in a consistent state a synchronisation algorithm had to be designed. We implemented a locking algorithm to do this.

To enable the network communication we had to design a protocol consisting of 20 different message types. The protocal defines how to setup a connection between two peers and how to notify the other peers of the new player, as well as how to notify other players of attacks and army movements.


Features:

  • Peer-to-peer application that can support up to 48 players.
  • Fast and frantic gameplay.
  • Shorter games and more action-packed than the orignal Risk.

Code Snippets:

Parallel troopers is written in Java. I worked mostly on the networking part and the GUI of the game. Here are some highlights of the code.

Synchronisation.java
This class manages the synchronisation of the clients. It includes the functions to request and release a lock and also keeps track of the clock.

IpFramePaint()
This function updates the ip frame on the left of the screen. It keeps track of the ip's, the number of lands owned by the player and if the player is ready to start the game.


Downloads:

You can download the game here.
NOTE: It is not possible to start 2 instances of the game on the same computer! To play you need at least 2 computers.

To play this game you need Java.
Start the game from the console with following command "java -jar ptroopers.jar".
Then one player has to enter the IP-adres of another player and click connect. When all players have clicked on "ready" the game can be started.