Maze Game - P2P


The maze is an N-by-N grid, consisting of N*N “cells”. Each cell can be the location of a “treasure”. At the start of the game, there are M treasures placed randomly at the grid (multiple treasures at the same cell are allowed).

The number of players is arbitrary. Each player aims to collect as many treasures as possible. A player collects one or more treasures when the player’s location is the same as the treasure’s location. A player cannot occupy a cell that another player occupies. The game is over when there are no more treasures on the grid. The game is distributed, i.e. each player connects to a remote game server (or simply, “the server”) via RMI. The players know the server’s host name and its port numbers. The server, on the other hand, does not know a priori the number of players or their IP addresses. 20 seconds after the first player requests a new game from the server, the game starts. Note that by that time several players may have joined the game. After the start of the game, no additional players are accepted by the server. The server keeps track of each player’s location and number of collected treasures, as well as of the location and number of available treasures on the grid. The players, on the other hand, only control the direction in which they move at the grid. At each step of the player, a player contacts the server giving the direction (S/E/N/W) in which the player wants to move.

Technologies Used:
Programming Language: Java