Sunday, September 23, 2012

Programming Challenge - Tank Game - Part 1

In this project we have to create a client program to communicate with a server and play the tank game. Five players will play at a given time in a map given by the server. The difference in this tank game is that the player of the client computer is not a human being but the client computer itself.
All the decision making of the players tank depends on the AI (Artificial intelligence) of the client. Therefore the AI development is of utmost importance in this project. Other than that a good user interface with some cool graphics is needed under the requirements of the client program.

Game Rules


The main purpose of this game is to gain more points than the his competitors. There are three methods to gain points in this tank game.

  •     Breaking bricks - Each time a shell (bullet) from a player damages a brick wall, a constant amount of points is added to the player’s point count.
  •     Collecting coins - Coins will appear in the map for a certain amount of time. A player can take the coins buy moving on to the cell before the coins disappear.
  •     Spoils of war - When a opponent get killed the coins will appear on the cell the opponent got killed. Any player who goes to that cell will get the coins but not necessarily the player who killed that player.

Health

The health of the tank is initially set to 100%, for each bullet it takes it looses 10% of the health. By acquiring health packs which appear on the map randomly a player can improve its health.
A health pack improve the health of a player by 20% of its health. there is no upper bound for the health of the player.


Killing

When a player kills one of its opponents 25% of the points of the opponent will be added to the players points.

If a player tries to move over water it will get killed, but the coins will not appear in the map when this happen.
When a player hit an obstacle a fixed amount of points will be deducted. if the player continuously loose points..

Server and Its massage protocol

Server is written in C# language. And it listens to clients on port 6000 and send messages to client from port 7000.

Game Server API

One request per second is allowed by the server. If more than one command is send within a minute it will respond with error message.

JOIN# -client has to issue this command to get connected to the sever to play the game. The server will reply appropriately to this as follows.

Join accepted message - If the request is granted the server will send a message informing the player position of the map and the map details (game initiation message).


Player position message: Then a massage containing all player positions will be sent if it was a successful join. If not one of the following will be sent.

PLAYERS_FULL# - If the server already has five players connected then this message will be send to inform that the request was rejected

ALREADY _ADDED# - When a client sends multiple JOIN# requests from the same IP when the client is already in the game.

GAME_ALREADY _STARTED# - if a client try to join a game that has already begun the server will reply with this message.

Directional Commands



UP# - This will turn the tank in the direction of north if its facing another direction, if not it will move one block in the direction of north, given that there are no obstacles in that direction.

DOWN# - This will turn the tank in the direction of south if its facing another direction if not it will move one block in the direction of south, given that there are no obstacles in that direction.

LEFT# - This will turn the tank in the direction of west if its facing another direction if not it will move one block in the direction of west, given that there are no obstacles in that direction.

RIGHT#  - This will turn the tank in the direction of east if its facing another direction if not it will move one block in the direction of east, given that there are no obstacles in that direction.

SHOOT# - This command will shoot a bullet in the direction the tank is facing.

Messages Send by the server in response to the commands made by the client

OBSTACLE# - If you a client tries to go to a cell occupied by an obstacle (brick or stone) this error message will be given by the server.

CELL_OCCUPIED# - If a client give direction to move to a cell which is occupied by opponent this error message will be given.

DEAD# - if a client request for any action after it is dead this error message will be given by the server.

TOO_QUICK# - If a client gives multiple commands within a second this error will be given by the server.

INVALID_CELL# - If the client tries to move out of the map this error message will be given by the server.

GAME_HAS_FINISHED# - After all the players are dead or the allotted time of the game is expired this message will be transmitted by the server to all the clients.

GAME_NOT_STARTED_YET#
- If a client request for any game specific commands such as SHOOT#, UP# before the game is started this error message will be given buy the server.

NOT_A_VALID_CONTESTANT# - If a client who is not eligible to play the game, who is not assigned a player number, request player specific tasks from the server this error will be made by the server.

In Part 2 I will bring you the real implementation of this Game, And how we developed the AI.

Content

Email:

Syndicators/Readers:

FaceBook: