Isnake Kucc2024 Report
Isnake Kucc2024 Report
on
FOR
DYPU
SUBMITTED BY
VISHAL M. SHINDE
PRN NO.SOM23MCA077
Date:
Place:
Pune
Examined by:
Examiner 1 :
Examiner :
DECLARATION
Date:
Place:
1
2 Abstract
This project aims to bring the fun and simplicity of snake game with some new features. It will
include computer controlled intelligent opponents whose aim will be to challenge the human
players. It will also have the multiplayer feature that will allow more than one players to play
the game over a network.
This project explores a new dimension in the traditional snake game to make it more
interesting and challenging. The simplicity of this game makes it an ideal candidate for a
minor project as we can focus on advanced topics like multiplayer functionality and
implementation of computer controlled intelligent opponents.
2
3 Objectives
This game aims to change the way people think of traditional snake game. It will offer the
experience of commercial multilayer games to the player retaining the simplicity of traditional
snake game.
● Create a snake game that will have all the functionality of traditional snake games.
● Introduce multilayer functionality in the game that will allow several players to play a
game simultaneously. It should be able to give the experience of a real time multiplayer
game to the players.
3
4 Programming Environment
We used several open source tools to develop this project:
All the developers of iSnake team used Netbeans IDE for the development of this
project.
These graphics development tools were extensively used for the development of User
Interface components. The illustrations presented in this report have also been prepared
using these open source tools.
● Gnuplot
The data obtained during profiling of two path finding algorithms viz. Blackmamba and
Viper was plotted using gnuplot.
All the project documents and this report were prepared using OpenOffice Writer 2.2.
During the development of iSnake Game Server Manager (GSM) @ SF.net, Wireshark
tool was used to analyze the network traffic.
4
5 Methodology
iSnake is a multiplayer version of traditional snake game (popular among cell phone gamers)
with computer controlled intelligent opponents that challenges the human players.
The player who hosts the game server is called “local player”. The iSnake Client Application
and Game Server run in separate execution domains. The iSnake Client App. for local player
communicates with the game server through network layer, just like other remote players, as
shown in illustration 1.
5
5.1 iSnake Client Application
iSnake client application refers to the application used to play snake game. A player joins
an already existing iSnake game server using this application.
6
5.1.4 Game Field Matrix
Game Controller maintains the complete state of the game using game field matrix.
It is a 2D array of size 58x58 (equal to the game field dimensions). Each game field object
has a unique identifier in the game field. Game Controller updates the cells of this matrix
in each cycle to register the changes that occur in the game.
The update of game field canvas occurs in the way similar to the refreshing
technique of a cathode ray monitor. The game field matrix and game field canvas are
updated in separate thread. The update of game field canvas starts by scanning each
column of the 1st row in the game field matrix, then 2nd row and so on upto the 58th row.
The game field is refreshed twice during each game cycle (two refresh cycle for game field
canvas for each game cycle). This is done make the movements in the game field
smoother.
7
received from the game server. Game Controller maintains the game cycle when the game
is running. This game cycle is synchronized with the game cycle of the game server. All the
updates to game field matrix are done during this cycle time. After expiry of each game
cycle the game field is repainted to reflect the changes in the game field.
8
5.2.3 Virtual Game Field
Game server maintains the state of the game using a 2D array of size 58x58 (similar
to that used by Game Controller – refer to 5.1.4).
It is maintained by the game server to check whether the food has been eaten and
whether any player has collide with the wall. It maintains the head coordinate (not the
coordinates for tails) of each player. The head coordinate of players is moved in each game
cycle and checked for the presence of wall/food in that coordinate position. Server Core
generates corresponding event (collide or food eaten) and all the active players are
informed about the event in the same cycle.
9
A typical response of Status Server is given below:
When the game is in "Waiting" mode, Server Core provides the facility of chat
messaging to the game players. During this state new players can join the game.
When all the players have sent signal to start the game, the Server Core changes
state to “Running” mode. If a new player tries to join the game, it receives a “NAK”
response. In this mode, Server Core maintains a game cycle time during which it receives
the movement coordinates (in terms of deltaX and deltaY) from the players. If a player
does not send any packet during this cycle time, server considers the movement coordinate
sent in last cycle for the current game cycle. After expiry of cycle time, game server
broadcasts a packet containing movement coordinates of each player to all the players
active in the game. The game server also checks if any player has eaten the food or if any
players have collided to the wall in each cycle.
10
path from given source (S) and target (T) coordinate pair considering the obstacles (if
any) present in the game field. The code name3 for these two implementations are:
Illustration 4: Module implementing two path finding algorithms replaces the Input Handler
module of standard iSnake Client application.
To know which of the two implementations perform better, we profiled them using a
simple JUnit test and the results were plotted using gnuplot:
11
Illustration 5: Turn around time for Illustration 6: Length of path returned
two path finding algorithms by the two path finding algorithms
The time elapsed between the instant of supplying the (source,target) coordinate
pair (S,T) to the algorithm and the instant when it returns a path for supplied (S,T) pair is
called turn around time. From the plot of illustration 5, it is clear that the turn around
time for Viper is always smaller as compared to Blackmamba.
The length of path (computed by counting the number of game field coordinates in
the path) returned by the two path finding algorithms is depicted by the plot of
illustration 6. It is clear from the plot that Viper implementation results in smaller paths
(and hence efficient) as compared to Blackmamba implementation.
NOTE: The value of turn around time and path length for the coordinate pairs 5,7,8 have
negative values for Blackmamba. This suggests that the algorithm was not able to compute a
path for given (S,T) pair in given timeout period (250 ms for this test).
12
5.4 iSnake Game Server Manager (GSM) @ SF.net
iSnake Game Server Manager (iSnake – GSM) hosted at http://isnake.sf.net is used to
manage all the information about iSnake game servers being hosted over the Internet.
The iSnake application deployed at our website has been digitally signed by the
iSnake team to address the security issues related to launch of Internet applications.
13
6 Project Management
The first thing we did before starting the work on iSnake was to register a project at
Sourceforge4. Apart from hosting services, it provided us several code and project management
services.
Illustration 8 shows the svn commit statistics for the isnake code repository at sourceforge. We
collaborated on project documents (including prototype designs, project plan, TODO list, etc)
using WIKI (http://isnake.wiki.sourceforge.net).
JUnit tests were developed to independently test some of the modules before integration. The
integration of modules developed by the three developers was performed in three phases:
● Phase 1 Integration (Sep. 28, 2007) chat functionality of the game was tested successfully
4 http://www.sourceforge.net
14
● Phase 2 Integration (Oct. 06, 2007) successful testing of basic version of multiplayer
snake game
● Phase 3 Integration (Feb 17 26, 2008) – integration of all the modules for iSnake 0.1
Beta release.
7 Documentation
Documentation of every task being done in the project was a priority for all the team members.
Almost every portion of the source code contains full code documentation conforming to
Javadoc standards.
Illustration 9: Screen shot of a snippet of source code showing method comments conforming to
javadoc standards.
There exists two path finding algorithms that implements intelligent opponent in the game viz
Blackmamba and Viper. These two algorithms have been fully documented with illustrations5.
The protocol devised for communication between game server and clients has been
documented in ANNEXD.
8 Limitations
The limitations of present implementation of iSnake are:
● The present implementation of iSnake can only be played in LAN. Due to large latency
time and bandwidth limitation, it cannot be played over the Internet.
● Path finding algorithms (Blackmamba and Viper) implemented in this game have their
own computation limitations which has been describe in ANNEX A,B.
5 Refer to ANNEX – A,B
● Full stress test of the application has not been done yet. Hence, the response of game
server in unpredictable situations cannot be handled properly.
9 Future Enhancements
● Port iSnake to cell phone platform and One Laptop Per Child – OLPC (which uses Sugar
Desktop environment). The presence of several connectivity options(Bluetooth, WIFI,
GPRS, CDMA) in cell phones makes it a very attractive platform for a multiplayer game
like iSnake. Local WIFI network formed by kids using OLPC laptops can be used as a
platform for iSnake's deployment.
● As iSnake game server communicates with remote playing using a well defined and
very simple protocol (Refer to ANNEX D), iSnake clients programmed in other
programming platform like Flash, Python, etc can be developed.
10 Conclusion
We were successful in creating a multiplayer version of traditional snake game. The computer
controlled intelligent opponents have been successfully tested in the game is a unique feature
of iSnake.
1. The Java Programming Language, by Ken Arnold, James Gosling, David Holmes
Websites
http://wiki.netbeans.org/wiki/view/CommunityDocs
http://inkscapetutorials.wordpress.com/
http://www.smashingmagazine.com/
http://java.sun.com/docs/books/tutorial/
5. Timing Framework
https://timingframework.dev.java.net/
6. JavaGaming.org's Forum
http://www.javagaming.org/forums/index.php
7. MIT Open Course Ware 6.831 User Interface Design and Implementation
http://ocw.mit.edu/OcwWeb/ElectricalEngineeringandComputerScience/6831Fall
2004/CourseHome/index.htm
http://theory.stanford.edu/~amitp/GameProgramming/
http://arianne.sourceforge.net/
http://community.java.net/javadesktop/
http://forum.java.sun.com
http://www.curiouscreature.org/
http://www.filthyrichclients.com/
http://warriors.eecs.umich.edu/games/papers/quakefinal.pdf
http://www.exampledepot.com/
http://mina.apache.org/
http://www.php.net/
18. Quantum Random Bit Generator Service (QRBG)
http://random.irb.hr/
ANNEX – A: Blackmamba – path finding algorithm
Proposed by: Abhishek Dutta
Refer to Illustration 10
1.3 Notations:
1.3.1 brNM
denotes a bounding rectangle that spans ( or touches ) N nodes along the xaxis
and M nodes along the yaxis.
ANNEX – A A1
1.3.2 spbrNM
denotes a source partial bounding rectangle that spans ( or touches ) N nodes
along the xaxis and M nodes along the yaxis.
1.3.3 tpbrNM
denotes a target partial bounding rectangle that spans ( or touches ) N nodes
along the xaxis and M nodes along the yaxis.
1.3.4 hpNM
denotes a hopping point (coordinate specified with reference to source) along
which spbrNM and tpbrNM are formed. This coordinate point is common to
both spbrNM and tpbrNM
A source (S) and target (T) can be placed in four possible ways such that they
lie on opposite ends of the diagonal. Considering the four position (A,B,C,D) as
depicted in Illustration 11, we have the following four cases:
ANNEX – A A2
1.3.5.4 'S' placed at position D and 'T' placed at position
Both path1 and path2 have equal traveling cost provided that no obstacles are present
along those paths. For any given br, if there exists a path from source to target inside the
br then it will be the shortest path.
ANNEX – A A3
Illustration 12: Four possible paths generated by
source and target partial bounding rectangles
(spbr,tpbr - depicted using red and green dotted
lines respectively) for a given hopping point
For any given (S,T) pair, we move the hopping point along the diagonal joining S and T.
● obstacles (wall) are present along the paths formed using the bounding and partial
bounding rectangles.
● No possible path can be found using all the possible combinations of the partial
bounding rectangles.
ANNEX – A A4
all possible path of an stage the next stage is checked. The series of steps taken to
obtain a path from 'S' to 'T' are:
4.1.1.2 Figure A3 four paths (refer to Illustration 12) formed along the source and
target partial bounding rectangle (spbr55, tpbr22) are checked for presence of
obstacle.
4.1.1.3 Figure A4 four paths (refer to Illustration 12) formed along the source and
target partial bounding rectangle (tpsbr44, ptbr33) are checked for presence of
obstacle.
4.1.1.4 Figure A5 four paths (refer to Illustration 12) formed along the source and
target partial bounding rectangle (tpsbr33, ptbr44) are checked for presence of
obstacle.
4.1.1.5 Figure A6 four paths (refer to Illustration 12) formed along the source and
target partial bounding rectangle (tpsbr22, ptbr55) are checked for presence of
obstacle.
4.1.1.6 Figure A7 This step is not necessary to execute as the task has already
been performed in Step 1 using the bounding rectangle (br66).
Let the time required to check whether a partial bounding rectangle has an obstacle
ANNEX – A A5
= T1
ANNEX – A A6
ANNEX – A A7
Illustration 13: Illustrations for “[A] Symmetric Bounding Rectangles (Simple Case)”
4.1.2 Backtracking
If 4.1.1.1 to 4.1.1.6 does not give a path from 'S' to 'T' the technique of backtracking
will be applied. To illustrate the process of backtracking let us consider the scenario
shown in Illustration 14.
ANNEX – A A8
Illustration 15: Next outer bounding rectangle
(br55) is checked for a path from node S1 to
T.
Backtracking involves moving to the next outer (as inner bounding rectangles do not
contain any path for sure) bounding rectangle a path to the target is found.
Illustration 15 shows the result of backtracking. Backtracking from S0 to S1 (the
next outer bounding rectangle) results in a bounding rectangle br55. This bounding
rectangle does not also result in any path from S1 to T. Hence, next outer bounding
rectangle is checked.
ANNEX – A A9
The next outer bounding rectangle (br66) is formed at node S1 as shown in
ANNEX – A A10
Illustration 16. This bounding rectangle has a path from S2 to T. Hence, the possible
path is calculated to reach from S2 to T.
By joining the paths formed from the above two steps can be combined to form a
path from S0 to T.
Although the vertex for next outer bounding rectangle (required for
backtracking) can be the next coordinate on the extended diagonal (as shown in
Illustration 15,16), a simple technique can greatly reduce the number of
backtracking steps of both source and target.
Let source (S) and target (T) be placed as shown in Illustration 18. A path from
S to T contains two edges. Path1 contains edge1 and edge2. Path2 contains
edge4 and edge3. While determining whether a path contains obstacle, the
algorithm must also determine which edges contains obstacles (if any).
ANNEX – A A11
Illustration 18: Four edges (1-4) formed out of a
bounding rectangle and the possible backtracking
vertices for S and T
We can apply the following algorithm to determine the outer rectangles required
during backtracking for source.
The outer rectangle for target, during backtracking, can be determined by applying
similar logic for edge2 and edge3.
This technique works for different orientation of source and target as described in
Section 1.3.5 Numbering of Paths
ANNEX – A A12
4.1.2.2 Merging the paths formed while backtracking
While backtracking several sub paths are created while requires to be merged to
form the final path from source to target. Let us consider a case as depicted in
Illustration 19.
Due to the presence of wall (green blocks), S and T has to backtrack to S' and T'
positions respectively. Here we obtain three sub paths which are:
Path from S to S' : depicted by red colored line from S to S' (SubPath1)
Path from S' to T : depicted by blue colored line from T to T' (SubPath2)
Path from T' to T : depicted by pink colored line from T' to T (SubPath3)
START
ANNEX – A A13
FinalPath = SubPath1
Step 2: Now perform the following operations for each cell coordinate
present in SubPath2 and SubPath2 (K=2,3)
cellCoordinate = SubPathK.getCellCoordinate()
} else {
END
ANNEX – A A14
Illustration 21. The algorithm applied in “[A] Symmetric Bounding Rectangles
(Simple Case)” can be now applied by considering the dummy nodes as normal
game field nodes free from any obstacles.
ANNEX – A A15
Illustration 23: The case can be converted to “[A]
Symmetric Bounding Rectangle (Simple Case)”
case by adding dummy nodes
5 Requirements
An important observation for iSnake game is that the obstacles in the game are not
dynamic. In other words, the obstacles remain constant until a given FOOD is eaten
by one of the players. Hence we can assume that the obstacle is constant during the
execution of this path finding algorithm.
START
ANNEX – A A16
Step 1: Let (x1,y1) = one corner of the bounding rectangle
(x2,y2) = diagonally opposite corner of the bounding rectangle
obstacle = a set coordinates defining the obstacle (wall)
Step 2: Repeat step 2 for each cell coordinate in obstacle
oc = obstacle.getCellCoordinate()
path1HasObstacle = true, path2HasObstacle = true
if( x >= x1 and x <= x2 ) {
if(!path1HasObstacle) {
if( x1y1.ggggetY().equals(y) )
path1HasObstacle =
true
}
if(!path2HasObstacle) {
if( x2y2.gggetY().equals(y) )
path2HasObstacle = true
}
}
if ( y >= y1 and y <= y2 ) {
if(!path1HasObstacle) {
if( x2y2.getX().equals(x) )
path1HasObstacle = true
}
if(!path2HasObstacle) {
if( x1y1.getX().equals(x) )
path2HasObstacle = true
}
}
Step 3: if(path1HasObstacle) {
if(path2HasObstacle)
return NO PATH POSSIBLE
else
return PATH2 is OBSTACLE FREE
ANNEX – A A17
} else {
ANNEX – A A18
if(path2HasObstacle)
return PATH1 is OBSTACLE FREE
else
return PATH1 and PATH2 are OBSTACLE FREE
}
END
6 Limitations
6.1 This algorithm does not consider the transparent game field boundary (entry to one
side of the field causes exit in the opposite side of the field as depicted in Illustration
24) during path calculation. Due to this limitation the computed path is not optimal.
6.2 The hopping points are always taken from the diagonal line joining the source and
target. Because of property of the algorithm, it is not able to compute paths when a
complex structure of wall, as shown in Illustration 25, is present. This is the reason why
Blackmamba implementation enters infinite recursion for such obstacles.
ANNEX – A A19
Illustration 25: Only 1 hopping point prevents this
algorithm from computing path in presence of a
complex structured wall
ANNEX – A A20
ANNEX – B: Viper – path finding algorithm
Proposed by: Suraj Sapkota
1 Assumptions
This algorithm assumes game field as follows:
● The rectangle with the dotted boarder is the view port(vp) of each player. Other
rectangles attached with it in each side are the virtual view port(vvp) in their
corresponding sides.
ANNEX – B B1
● Finally considering all these, the aim of this algorithm is to find all (there may be
multiple path of same distance) shortest path from the snake (head) to food. However
as a result it will return only one among those paths.
1. This algorithm begins with splitting all the game field into small rectangles (Fundamental
open rectangle7 (FOR8)), say R1, R2, R3, ... Rn. If gamefield (only view port), as a whole
is said to be G. Then mathematically the wall, W can be defined as:
W = G R1 U R2 U R3 U ... U Rn
Broadly, this algorithm deals with splitting the game field into several (as many) rectangles
such that, the union of all these small rectangles result in the game field that exclude wall. ie,
the snake can move safely from any point in the rectangle(Ri) to any other point within the
same rectangle(Ri)and hence called Open rectangles (OR).
7 Open rectangle is a rectangle that does not contain any wall. Within it snake can move freely.
8 The algorithm of generating FOR is discussed later.
ANNEX – B B2
Illustration 2: Slitted into 6 small
pieces of rectangle.
2. Next we define Gate9 (Gate as in real life is a way to move from a FOR to another adjacent
FOR) calculate the shortest distance between each two Gates of each FOR (eg: the shortest
distance between the rectangles R1 and R5 are determined by the distance between the two
gates of R3 shared with R1 and R5 respectively).
3. After the calculation of the shortest path, a graph as shown in Illustration 4 is formed.
Illustration 4: Graph
In the above graph
ii. The dark line shows a 1 step indirect connection between those rectangles that are not
connected directly.
9 A gate must be common to only two FOR.
ANNEX – B B3
iii. Sij, beside with the vertex, (in graph) denotes that FORi is connected to FORj through this
vertex and vice versa. This can also be called indirect path. And it posses the path
distance.
iv. There may be multiple indirect path. Eg: We can move form 2 to 5 (S25) in two
different ways: via 3 or 5.
Some data that are associated with the rectangle (node in the graph) is shown below.
Illustration 6: Path for a sample case. Illustration 7: Zoomed view of "Illustration 6"
ANNEX – B B4
The above sample case shown in illustration 6 and 7, shows the path calculated by the
algorithm from the snake (red one pointed by an arrow A) to the food (blue one pointed by an
arrow F). The points pointed by the arrows A, B, C, D, E and F are points (Hoping Points) that
the intelligent player must pass through. And thus allowing multiple possibility for path.
The path is multiple because, there exist multiple way to go from A to B and E to F. Further
the rectangles as formed by the points A and B ( E and F ) can also be called Derived open
rectangle (as it doesn't contain any wall, and hence allows free movement of the snake inside
it).
ANNEX – B B5
Till this step the rectangle was not bounded (either in
all four sides (envelop) or in two sides(top and bottom)
(cylinder)). From this step onwardthe sliced game field
would be bounded.
6. As earlier again try to slice the gamefield in the anticlockwise direction starting from
left. It will result in two more rectangle R7 and R8. Illustration15.
7. For Further Optimization we proceed by breaking down the rectangle that touches
itself (eg: in this case, the top edged of rectangle R1 touch itself to its bottom edge). These
type of rectangles are divided in the middle. This results in best utilization of the transparency
of the Game Field.
ANNEX – B B6
Illustration 16: The Final Result
ANNEX – B B7
5 Salient Features:
● As most of the processing is done before the actual game starts, it must reduce the
the processing time during the game-time.
● The concept of open-rectangle allows multiple path, and hence within it the snake can
be moved randomly towards the specified point. And hence it is intelligent.
● Furthermore, during the calculation of the path the snake can move within the FOR in which it
currently lie.
6 Limitations:
● If the number of FOR increases to too high, then it will obviously be tough and slow
to determine the shortest path.
ANNEX – B B8
ANNEX – C: Program flow
Illustration 26: iSnake game application enters in STAGE-1 and exits through STAGE-5
Illustration 27: iSnake game application starts in STAGE-1 and this stage involves connection to
game server specified by the player
NOTE: "EXT" refers to the actions that are triggered by Client Network Interface module when
messages are received from game server
ANNEX – C C1
Illustration 28: In STAGE-2 players can chat with each other. The game will start only when all the
players connected to the game server send READY signal
NOTE: "EXT" refers to the actions that are triggered by Client Network Interface module when
messages are received from game server
ANNEX – C C2
Illustration 29: STAGE-3 involves receiving different game data (like wall coordinates, food
coordinate, snakes start position, etc)
NOTE: "EXT" refers to the actions that are triggered by Client Network Interface module when
messages are received from game server
ANNEX – C C3
Illustration 30: STAGE-4 involves synchronization with the game server
NOTE: "EXT" refers to the actions that are triggered by Client Network Interface module when
messages are received from game server
ANNEX – C C4
Illustration 31: STAGE-5 represents the state when game is being played
NOTE: "EXT" refers to the actions that are triggered by Client Network Interface module when
messages are received from game server
ANNEX – C C5
ANNEX – D: Inter Snake Communication Protocol
The communication between the game server and client applications is done using the Inter
Snake Communication Protocol (ISCP). The protocol contains five different classes. These are
listed below:
ChatMessage Transmits the chat message. Works only before the actual
game starts.
LevelData Sends data required on level change (food, wall, score, life,
etc). Sent initially when the actual game begins and then
after every level change.
The communication packets are encoded in byte format for the purpose of transmission and
are decoded in similar fashion. The encoding and decoding of packets in client side is handled
by ClientEncoder and ClientDecoder respectively. Similar for game server, encoding and
decoding is handled by ServerEncoder and ServerDecoder respectively.
For instance, the server encoder for chat message is known as ChatServerEncoder. The
encoders and decoders are placed under net.sf.isnake.codec.
On the basis of communication packet flow, we can classify the communication basically into
two types:
ANNEX – D D1
encodes the packet with necessary data. Send it to server in flipped order. Flipping is
required so that it gets received in correct order at the other end. The server decodes it.
The server reencodes the data with some further informations (if required such as
sender's Id) and flips it. This packet is retransmitted to clients where it is decoded. The
communication cycle is shown below:
The five classes of communication can send various messages. All the messages are decoded
the same way they are encoded. Following conventions are used in depicting the encoding
over here:
Symbol Meaning
<> Shows fields to be sent along with identifier
() Shows the data type of the field. However, all the fields are converted into byte
while encoding and on decoding they are received as bytes and converted to
proper data type.
id Represents the player id (an integer used to uniquely identify a player in the
game).
[] The fields within [] are part of an array in the protocol class.
Identifier CH
ClientEncoder CH<to_id(byte)><len_of_message(short)><message(string)>
ServerEncoder CH<from_id(byte)><to_id(byte)><len_of_message(short)><messag
e(string)>
Class: Information
1 Packet Player info
Identifier IN
Description Is used to transport the informations of a player viz; name, color and
location.
ClientEncoder IN<info_len(short)><name:color:location(string)>
ServerEncoder IN<info_len(short)><id:name:color:location(string)>
Class: ControlSignal
1 Packet Acknowledgment
Identifier AK
Description This packet is sent when a client successfully receives Level data. The
status_code field has been reserved for future enhancements. As of
now it is sent as 0.
ClientEncoder AK
ServerEncoder AK<id(byte)><status_code(byte)>
2 Packet Quit
Identifier QT
ANNEX – D D3
Type Client Initiated
ClientEncoder QT
ServerEncoder QT<id(byte)>
3 Packet Ready
Identifier RY
Description Is sent when the user specifies his readiness to start the game.
ClientEncoder RY
ServerEncoder RY<id(byte)><status_code(byte)>
4 Packet ID
Identifier ID
Description This packet is sent by server to client to assign an id to the player. This
is done as soon as the client sends his information.
ServerEncoder ID<id(byte)>
5 Packet Start
Identifier ST
ANNEX – D D4
level synchronization task before beginning of a level and status_code 2
is a signal to start the actual level play.
ServerEncoder ST<status_code(byte)>
6 Packet Stop
Identifier SP
ServerEncoder SP<status_code(byte)>
7 Packet Force
Identifier FR
Description This communication packet forces a player to send a ready packet when
all others have expressed their willingness to begin the game.
ServerEncoder FR<id(byte)><status_code(byte)>
8 Packet No Acknowledgment
Identifier NK
Description This packet is sent by server when the information supplied by client is
not valid. status_code here represents field which has invalid data.
Invalid data occurs when information field contains reserved characters
or duplicate entry.
ServerEncoder NK<id(byte)><status_code(byte)>
Class: LevelData
ANNEX – D D5
1 Packet Begin from
Identifier BF
Description The packet sends starting coordinate of all the players in a single
packet. The player begins level from this coordinate and is reset to this
coordinate on collision.
ServerEncoder BF<3*no_of_players(byte)>[<id(byte)><x_coordinate(byte)><y_co
ordinate(byte)>]
2 Packet Score
Identifier SC
Description Sends score of all the players in the packet on beginning of a level.
ServerEncoder SC<8*2*no_of_players(byte)>[<id(long)><score(long)>]
3 Packet Level
Identifier LV
ServerEncoder LV<level_number(byte)>
4 Packet Life
Identifier LF
Description Sends the life count for each player on beginning of a level.
ServerEncoder LF<2*no_of_players(byte)>[<id(byte)><life_count(byte)>]
ANNEX – D D6
5 Packet Wall
Identifier WL
ServerEncoder WL<2*wall_length(short)>[<x_coordinate(byte)><y_coordinate(byte
)>]
6 Packet Food
Identifier FD
Description Sends the food coordinates to the clients on the beginning of a level.
ServerEncoder FD[<x_coordinate(byte)><y_coordinate(byte)>]
Class: Move
1 Packet Collide
Identifier CL
Description The packet is sent when a player looses a life. Possibility of more than
one players colliding on same turn has been taken into account. At
present, however, we are checking the collision on server and the
communication is thus Server Initiated.
ClientEncoder CL
ServerEncoder CL<no_of_players_collided(byte)>[<collided_player_id(byte)>]
ANNEX – D D7
2 Packet Move
Identifier MV
Description Carries the change in x and y (dxdy) of the clients to the server. Server
merges change in coordinate of all the clients in a new MV packet and
transmits to the clients.
ClientEncoder MV[<id(byte)><dx(byte)><dy(byte)>]
ServerEncoder MV<3*no_of_players(byte)>[<id(byte)><dx(byte)><dy(byte)>]
3 Packet Eaten
Identifier ET
Description Server sends the packet whenever the food gets eaten. This packet also
initiates the generation of Food packet as a level can have more than
one food.
ClientEncoder ET
ServerEncoder ET<eaten_id(byte)>
FD[<x_coordinate(byte)><y_coordinate(byte)>]
ANNEX – D D8