3. Turn Flow - RMHSProgrammingClub/Bot-Server GitHub Wiki
At the start of each turn you are sent START_TURN
by the server and after that the server sends the client information about the bot in JSON.
The table below describes what you are given (Note: This is subject to change. Please see connection.rb for further information).
JSON | Description |
---|---|
x | The x position of the current bot |
y | The y position of the current bot |
angle | The angle of the the current bot |
health | The health of the the current bot |
ap | The number of Action Points of the the current bot |
mana | How much Mana the client has left |
vision | What the robot can see (See Vision Explained) |
An example of what the client is sent is (the real JSON will have no new lines and no spacing):
{
"x": 10,
"y": 8,
"angle": 180,
"health": 100,
"ap": 10,
"mana": 105,
"vision": [
{
"type": "BOT",
"team": 1,
"x": 10,
"y": 8,
"angle": 180,
"health": 100
}
]
}
After you are given the bot information the client must send back its actions. Each action must be separated by a newline.
The table below gives each action's code. Italicized codes are arguments sent by the client
Action | Code |
---|---|
Move | MOVE x y |
Turn | TURN degrees |
Shoot | SHOOT |
Place block | PLACE x y |
Spawn Bot | SPAWN |
After your actions are sent you must send END
to the server to indicate that you are done with your turn. The server then executes your action and lets the other client take a turn. After that client takes a turn your client is given another turn with a new bot.