Ant bot input output

jmcarthur edited this page Jul 10, 2011 · 7 revisions

Bot Input

Parameter Information:
At the start of a game, each bot is passed general parameters about the game, this begins with "turn 0" on its own line. Parameter will then be passed on separate lines with the following format:

type value

All values are integers. The set of parameter types may be added to the spec in the future, but none will be removed once they have been added. Here is the current list of parameters that will be passed to the bots:

"loadtime"       # in milliseconds
"turntime"       # in milliseconds
"rows"           # number of rows in the map
"cols"           # number of columns in the map
"turns"          # maximum number of turns in the game
"viewradius2"    # view radius squared
"attackradius2"  # battle radius squared
"spawnradius2"   # spawn radius squared
"player_seed"    # seed for random number generator, useful for reproducibility

Once all parameters have been passed you will receive "ready" on a separate line, at which point you are free to set up for as long as the loadtime specifies. Once you have finished setting up, you are to output "go" on its own line.

Turn Information:
Each following turn begins with the following line:

turn turnNo

You are then passed information about the squares you can currently see with the following format:

f row col                            # food square
w row col                            # water square
a row col owner                      # live ant square
d row col owner                      # dead ant

The end of input for a turn is indicated by receiving "go" on its own line.

Information about a water square will only be sent the first turn in which it is visible by one of your live ants. You will be passed information for live ants and food squares every turn they are within sight of one of your currently live ants.

Information is given for ants that died during the battle resolution of the previous turn if it is in a square currently visible by one of your live ants. These squares are merely for your information if you wish to use them, they can otherwise be thought of as land and moved into that turn.

When the game is over, all players will receive the word "end". The winner of the game will receive state information for the final state of the game, in the same format as above. All other players (the losers) have no more ants and thus have no way of seeing the final game state.

All players will then receive two lines giving the number of players and scores in the following format:

players noPlayers
score p1Score ... pnScore

Sample Input:
Below is sample input for player 'a' in the above game:

turn 0
loadtime 3000  
turntime 1000  
rows 20  
cols 20  
turns 500  
viewradius2 55  
attackradius2 5  
spawnradius2 1  
player_seed 42

turn 1
f 6 5
w 7 6
a 7 9 1 
a 10 8 0
a 10 9 0

players 2
score 1 0
f 6 5
d 7 8 1 
a 9 8 0
a 9 9 0

Below is sample input for player 'b' in the above game, starting from the first turn (input for turn 0 is identical to player 'a'):

turn 1
f 6 5
w 7 6
a 7 9 0 
a 10 8 1
a 10 9 1

players 2
score 1 0

Bot Output

Once the bot has been passed the parameters at the start of the game and it has finished setting up, it is to output "go" on its own line to the engine.

Each bot may move any number of their ants each turn either north, east, south or west, provided the destination square is not water. Each move should be on a separate line with the following format:

o row col direction

Grid indexes start from zero and directions are to be passed as either 'N', 'E', 'S' or 'W'. At the end of each turn, bots are to output "go" to indicate to the engine that it has finished issuing moves.

Sample Output:
Below is sample output from player 'a' in the above game:

o 10 8 N 
o 10 9 N

Below is sample output from player 'b' in the above game:

o 7 9 W