A simple Peer to Peer (P2P) distributed multiplayer game system (2D), that allows the players to connect with other players and explore an open grid world and collect rewards.
Players have the flexibility to join and leave the system at their discretion, engaging in gameplay until they choose to exit the system. In this game, the strategy revolves around gathering reward points in a distributed game map. The ultimate goal is for the player to amass the highest score to secure victory.
-
Clone the repo
git clone https://github.com/harinda05/Strategiafi.git
-
Install Maven packages
mvn clean install
Bootstrap Server: Required to join the game network at the very first step. The newly joined server would receive connection addresses and ports, which then can be used to communicate directly with.
-
java -cp dist-sys.jar org.uoh.distributed.server.BootstrapServer
Peer Node: Actual local game node. Supports multiplayer gaming. All the players should be in the same network. *
java -cp dist-sys.jar org.uoh.distributed.game.GameWindow
Shared distributed state:
In this game there are few entities managed globally across all nodes. The global map, their resources/coins and their availability on the map, scores of each player will be handled by each node but it will be globally distributed across all nodes. The global state is updated when new nodes join, player movements, and resource/coin consumption.
Synchronization & Consistency:
The state is synchronized with each player when they move or pick a coin. Player movements are synchronized across the global map by utilizing multicast messaging between the nodes.
Consensus
_Gameplay Scenario: It is a gameplay assumption that the coins in the player’s map can only be collected once by a single player interacting with the game. Once a coin has been collected it will disappear from the distributed map, and the player who collected the coin will have its score increased, by the value assigned to that coin.
Since the map is a distributed state maintained across the network and synchronized among all the player nodes, there can be situations where two players compete for the same coin and try to collect it at the same time. In that case, the network should reach a consensus on which player is allowed to collect the coin, and thus avoid a double spending scenario.
To facilitate this, a distributed voting mechanism based on a simplified version of Paxos algorithm was introduced and implemented in the system. We couldn’t find a compatible Paxos Java library for this and opted to write our own Paxos implementation from scratch.
Distributed under the Apache License 2.0. See LICENSE.txt
for more information.
This was developed as part of a project assignment for the course Distributed Systems, Master's in Computer Science at the University of Helsinki, Finland. Focus was on demonstrating distributed aspects of systems rather than on solid game logics.