General Rules
No prior knowledge of networking is required to participate in this event.
Languages
The languages for the clients are restricted to C / C++ and Java .
For communication with the server we will provide ready made Clients in C, C++ and Java, as a template to write the participants code. It will have all the codes required for the networking written in it. All the participant needs to do is take the input string (Server message) and generate the output string (Client request).
The Server
For connecting to the server the client will send the message 'connect'. In response the server will send a message confirming the connection. The format of the message will be connected;botid'. Here botid will be a number (greater than or equal to zero) which identifies the particular client. This part of the code for connecting to the server is already provided in the clients. The botid is directly accessible by the user, in the variable 'botid'.
The server initially waits for 5 seconds for clients to connect, after which it will accept no further connection requests.
In each cycle the server waits for a default period of 2000 milliseconds for incoming requests. This period can be set to any value through command line arguments. If we want to run the server with 1000 millisecond cycles then we type the following in the command prompt:
>java Server 1000
In each cycle only one request from each client can be processed. If a client sends more than one command then only the last sent request is processed.
The Client
In each cycle a bot can move only one square or read from the shared memory or write to the shared memory.
The movement commands are :
n ' for moving to the square above the bot, in the vision matrix
s ' for moving down
e ' for moving right
w ' for moving left
ne ' for moving to top-right square
nw ' for moving to top-left square
se ' for moving to the bottom-right square
sw ' for moving to the bottom-left square
x ' for no movement
The command to read the shared memory is read'.
The command to write to the shared memory is write;message' where message is the string of maximum 20 bytes in length that the client wants to write to the shared memory.
The server responds by returning the environment info for the movement and write' commands. For read' commands it returns the shared memory.
Important: If you are using Java to code the client, then you must not use Java Threads in your code. We may use Java Threads to run many clients in parallel so there may be thread clashes.
Environment Information
The environment info can be interpreted as follows:
1st byte - Size of the vision matrix (the area the bot can see). If the first byte is n (integer) then the size of the matrix is (2*n+1)x(2*n+1). So you need to convert that byte to integer to get n'.
2nd byte Separator (semi-colon)
Subsequent bytes Row wise definition of the vision matrix
The definition of the vision matrix has the following specifications
A ' Square at height -4
B ' square at height -3
C ' Square at height -2
D ' Square at height -1
E ' Square at height 0
F ' Square at height 1
G ' Square at height 2
H ' Square at height 3
I ' Square at height 4
O ' Obstacle
R ' Another robot
S ' Bot itself
U ' Undefined
The bot cannot see beyond obstacles (unless it is situated on a square with a height factor greater than or equal to 3). The squares beyond the obstacles are marked undefined.
Suppose the server returns
3;EEDBOUUEDBBUUEEDBBOUEEDSCBCEEDCCBOEEEDDBUEFFEEOU
This represents a matrix of size 7x7 whose elements follow it. The matrix will be interpreted row first, that is the above message will be interpreted as the following matrix:
EEDBOUU
EEDBBUU
EEDBBOU
EEDSCBC
EEDCCBO
EEEDDBU
EFFEEOU
Shared Memory
The shared memory is a chunk of memory common to all the bots. All the bots can read and write from it.
The messages to be written to the shared memory can be a maximum of 20 bytes in length. The characters beyond the first 20 bytes will be ignored.
The shared memory can hold a total of 20 messages . When the 20 message space gets filled up, older messages will start getting deleted, and replaced by newer messages.
When a bot wants to read the shared memory, then the whole memory (i.e. maximum 20 latest messages) is returned in the following format:
msg1,cycle-cycle1; Msg2,cycle-cycle2;
- Here msg1' and msg2' are the messages written by two bots earlier to the read command.
- cycle' is the current server cycle. cycle1' is the server cycle when the bot wrote the message to the shared memory. cycle-cycle1' is always negative.
So basically a single message will be interpreted as the following:
Msg(20 Bytes), Relative-Cycle(4 Bytes);
Further Queries
See the mission mars forum in the robotix forum for queries and clarifications regarding the rules. We will be posting regular updates and tutorials regarding the event on the forum. Discussions regarding the event will also be held on this forum.