Battleship is played in two stages :
At each turn, the arena made HTTP(s) queries containing POST parameters, to your bots.
They must respond to the specifications below.
Parameter | Description |
---|---|
game |
String, will always "Battleship". Can be used if your url is used for several games. |
match_id |
String. Match the following regular expression : ^[0-9]+-(1|2)$ The first number (digits before the hyphen) identified the game. The number after the hyphen indicates whether you are the first or second bot in the order to play. It will serve you if your AI makes statistics on games. |
act |
Can take two values :
|
opponent |
String identifying your opponent. So you can grow up delirium by developping an algorithm that adapts depending on the opponent and the history of fighting with it. |
width | Integer, between 1 and 100, inclusive, indicates the width of the map. |
height | Integer, between 1 and 100, inclusive, indicates the height of the map. |
ship1 | Integer, between 0 and 10, inclusive, indicates the number of boats with length of 1 box to set. |
ship2 | Integer, between 0 and 10, inclusive, indicates the number of boats with length of 2 box to set. |
... | ... |
ship6 | Integer, between 0 and 10, inclusive, indicates the number of boats with length of 6 box to set. |
your_strikes |
String, representing an array in JSON format. [ ] In the second round of game, it contains the previous shot and the result : [{"target":"2,0","result":""}] In the third round of play, the two previous shots : [{"target":"2,0","result":"hit"},{"target":"5,1","result":"hit"}] Each shot is a sub array for which :
|
his_strikes | Same except that this is the shot of the opponent. |
Lors de l'initialisation d'une partie StupidIA VS StupidsIA, l'arène a envoyé au bot les parametres POST suivants : During initialization of part StupidIA VS StupidIA, the arena send to your bot the following parameters in POST :
game=Battleship&match_id=828-1&act=init&opponent=stupidIA&width=10&height=10&ship1=0&ship2=1&ship3=2&ship4=1&ship5=1&ship6=0
Or, more readable :
[game] => Battleship [match_id] => 828-1 [act] => init [opponent] => stupidIA [width] => 10 [height] => 10 [ship1] => 0 [ship2] => 1 [ship3] => 2 [ship4] => 1 [ship5] => 1 [ship6] => 0
The HTTP page that must generate your bot contains the position of ships.
You return a character string that is a JSON array with as many records as ships.
Each ship is defined by the coordinates of its ends.
["3,3-3,7","2,1-2,4","0,1-0,3","7,3-7,1","8,8-7,8"]
Of course if your boat overlap, or if their number and length does not match the demand of the arena, you lose the game.
The order of the boats does not matter.
Similarly, for a boat, the order of its points does not matter either.
Seen on the grid, the example above would be :
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | |
0 | ||||||||||
1 | ||||||||||
2 | ||||||||||
3 | ||||||||||
4 | ||||||||||
5 | ||||||||||
6 | ||||||||||
7 | ||||||||||
8 | ||||||||||
9 |
Examples of parameters sent by the arena.
[game] => Battleship [match_id] => 834-1 [act] => fight [opponent] => stupidIA [width] => 10 [height] => 10 [ship1] => 0 [ship2] => 1 [ship3] => 2 [ship4] => 1 [ship5] => 1 [ship6] => 0 [your_strikes] => [] [his_strikes] => []
[game] => Battleship [match_id] => 834-1 [act] => fight [opponent] => stupidIA [width] => 10 [height] => 10 [ship1] => 0 [ship2] => 1 [ship3] => 2 [ship4] => 1 [ship5] => 1 [ship6] => 0 [your_strikes] => [{"target":"4,6","result":""}] [his_strikes] => [{"target":"7,8","result":""}]
[game] => Battleship [match_id] => 834-1 [act] => fight [opponent] => stupidIA [width] => 10 [height] => 10 [ship1] => 0 [ship2] => 1 [ship3] => 2 [ship4] => 1 [ship5] => 1 [ship6] => 0 [your_strikes] => [{"target":"4,6","result":""},{"target":"3,9","result":"hit"}] [his_strikes] => [{"target":"7,8","result":""},{"target":"7,8","result":""}]
6,9
To shoot on the coordinates x=6 y=9