botsArena/src/arenas/Battleship/doc-en.html

378 lines
12 KiB
HTML
Raw Normal View History

2015-12-27 16:53:58 +01:00
<p>
Battleship is played in two stages :
</p>
<ul>
<li>Boats placement on maps</li>
<li>Shootout</li>
</ul>
2015-12-27 16:53:58 +01:00
<p>
At each turn, the arena made HTTP(s) queries containing POST parameters, to your bots.<br/>
They must respond to the specifications below.
</p>
<h2>Descriptif des paramètres envoyés par l'arène</h2>
<table class="tabledoc">
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
<tr>
<td>game</td>
<td>
String, will always "Battleship".<br/>
Can be used if your url is used for several games.
</td>
</tr>
<tr>
<td>match_id</td>
<td>
String. Match the following regular expression : ^[0-9]+-(1|2)$<br/>
The first number (digits before the hyphen) identified the game.<br/>
The number after the hyphen indicates whether you are the first or second bot in the order to play.<br/>
It will serve you if your AI makes statistics on games.
</td>
</tr>
<tr>
<td>act</td>
<td>
Can take two values :<br/>
<ul>
<li>"init" : We start the game, you must place your ships</li>
<li>"fight" : You send a shot</li>
</ul>
</td>
</tr>
<tr>
<td>opponent</td>
<td>
String identifying your opponent.<br/>
So you can grow up delirium by developping an algorithm that adapts depending on the opponent and the history of fighting with it.
</td>
</tr>
<tr>
<td>width</td>
<td>Integer, between 1 and 100, inclusive, indicates the width of the map.</td>
</tr>
<tr>
<td>height</td>
<td>Integer, between 1 and 100, inclusive, indicates the height of the map.</td>
</tr>
<tr>
<td>ship1</td>
<td>Integer, between 0 and 10, inclusive, indicates the number of boats with length of 1 box to set.</td>
</tr>
<tr>
<td>ship2</td>
<td>Integer, between 0 and 10, inclusive, indicates the number of boats with length of 2 box to set.</td>
</tr>
<tr>
<td>...</td>
<td>...</td>
</tr>
<tr>
<td>ship6</td>
<td>Integer, between 0 and 10, inclusive, indicates the number of boats with length of 6 box to set.</td>
</tr>
<tr>
<td>your_strikes</td>
<td>
<p>
String, representing an array in JSON format.<br/>
This parameter is only sent when the game is in shooting phase (act=fight).<br/>
It tells you the shots you've already made and their results.<br/>
In the first round of play, it is an empty array.
</p>
<p>
<i>[ ]</i>
</p>
<p>
In the second round of game, it contains the previous shot and the result :
</p>
<p>
<i>[{"target":"2,0","result":""}]</i>
</p>
<p>
In the third round of play, the two previous shots :
</p>
<p>
<i>[{"target":"2,0","result":"hit"},{"target":"5,1","result":"hit"}]</i>
</p>
<p>
Each shot is a sub array for which :
</p>
<ul>
<li>The index target indicates the coordinates of the target shooting x,y</li>
<li>
result may be :
<ul>
<li>Empty "" means that the shot did not hit anything</li>
<li>"hit" An enemy ship has been hit</li>
<li>"hit and sunk" An enemy ship was hit and sunk</li>
</ul>
</li>
</ul>
</td>
</tr>
<tr>
<td>his_strikes</td>
<td>Same except that this is the shot of the opponent.</td>
</tr>
</table>
2015-12-27 16:53:58 +01:00
<h2>What must return your bot</h2>
<h3>During initialization of the game</h3>
<p>
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 :
</p>
<pre>
game=Battleship&amp;match_id=828-1&amp;act=init&amp;opponent=stupidIA&amp;width=10&amp;height=10&amp;ship1=0&amp;ship2=1&amp;ship3=2&amp;ship4=1&amp;ship5=1&amp;ship6=0
</pre>
<p>
Or, more readable :
</p>
<pre>
2015-12-27 16:53:58 +01:00
[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
</pre>
2015-12-27 16:53:58 +01:00
<p>
The HTTP page that must generate your bot contains the position of ships.
</p>
<p>
You return a character string that is a JSON array with as many records as ships.<br/>
Each ship is defined by the coordinates of its ends.
</p>
<ul>
2015-12-27 16:53:58 +01:00
<li>The grid starts at the point 0,0.</li>
<li>Integers, ordinate and abscissa, defining a point, are separated by a comma &quot;,&quot;.</li>
<li>The two points defining the ends a ship shall be separated by a hyphen &quot;-&quot;.</li>
</ul>
2015-12-27 16:53:58 +01:00
<h4>Placement example of 5 boats with respective sizes 5, 4, 3, 3, 2 boxes :</h4>
<pre>
2015-12-27 16:53:58 +01:00
["3,3-3,7","2,1-2,4","0,1-0,3","7,3-7,1","8,8-7,8"]
</pre>
2015-12-27 16:53:58 +01:00
<p>
Of course if your boat overlap, or if their number and length does not match the demand of the arena, you lose the game.
</p>
<p>
The order of the boats does not matter.<br/>
Similarly, for a boat, the order of its points does not matter either.
</p>
<p>
Seen on the grid, the example above would be :
</p>
<table class="battleshipGrid nofloat" id="tbl1">
2015-12-27 16:53:58 +01:00
<tr>
<td></td>
<td>0</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
<tr>
<td>0</td>
<td class="empty" id="bot1-0-0"></td>
<td class="shipOn" id="bot1-0-1"></td>
<td class="shipOn" id="bot1-0-2"></td>
<td class="shipOn" id="bot1-0-3"></td>
<td class="empty" id="bot1-0-4"></td>
<td class="empty" id="bot1-0-5"></td>
<td class="empty" id="bot1-0-6"></td>
<td class="empty" id="bot1-0-7"></td>
<td class="empty" id="bot1-0-8"></td>
<td class="empty" id="bot1-0-9"></td>
</tr>
<tr>
<td>1</td>
<td class="empty" id="bot1-1-0"></td>
<td class="empty" id="bot1-1-1"></td>
<td class="empty" id="bot1-1-2"></td>
<td class="empty" id="bot1-1-3"></td>
<td class="empty" id="bot1-1-4"></td>
<td class="empty" id="bot1-1-5"></td>
<td class="empty" id="bot1-1-6"></td>
<td class="empty" id="bot1-1-7"></td>
<td class="empty" id="bot1-1-8"></td>
<td class="empty" id="bot1-1-9"></td>
</tr>
<tr>
<td>2</td>
<td class="empty" id="bot1-2-0"></td>
<td class="shipOn" id="bot1-2-1"></td>
<td class="shipOn" id="bot1-2-2"></td>
<td class="shipOn" id="bot1-2-3"></td>
<td class="shipOn" id="bot1-2-4"></td>
<td class="empty" id="bot1-2-5"></td>
<td class="empty" id="bot1-2-6"></td>
<td class="empty" id="bot1-2-7"></td>
<td class="empty" id="bot1-2-8"></td>
<td class="empty" id="bot1-2-9"></td>
</tr>
<tr>
<td>3</td>
<td class="empty" id="bot1-3-0"></td>
<td class="empty" id="bot1-3-1"></td>
<td class="empty" id="bot1-3-2"></td>
<td class="shipOn" id="bot1-3-3"></td>
<td class="shipOn" id="bot1-3-4"></td>
<td class="shipOn" id="bot1-3-5"></td>
<td class="shipOn" id="bot1-3-6"></td>
<td class="shipOn" id="bot1-3-7"></td>
<td class="empty" id="bot1-3-8"></td>
<td class="empty" id="bot1-3-9"></td>
</tr>
<tr>
<td>4</td>
<td class="empty" id="bot1-4-0"></td>
<td class="empty" id="bot1-4-1"></td>
<td class="empty" id="bot1-4-2"></td>
<td class="empty" id="bot1-4-3"></td>
<td class="empty" id="bot1-4-4"></td>
<td class="empty" id="bot1-4-5"></td>
<td class="empty" id="bot1-4-6"></td>
<td class="empty" id="bot1-4-7"></td>
<td class="empty" id="bot1-4-8"></td>
<td class="empty" id="bot1-4-9"></td>
</tr>
<tr>
<td>5</td>
<td class="empty" id="bot1-5-0"></td>
<td class="empty" id="bot1-5-1"></td>
<td class="empty" id="bot1-5-2"></td>
<td class="empty" id="bot1-5-3"></td>
<td class="empty" id="bot1-5-4"></td>
<td class="empty" id="bot1-5-5"></td>
<td class="empty" id="bot1-5-6"></td>
<td class="empty" id="bot1-5-7"></td>
<td class="empty" id="bot1-5-8"></td>
<td class="empty" id="bot1-5-9"></td>
</tr>
<tr>
<td>6</td>
<td class="empty" id="bot1-6-0"></td>
<td class="empty" id="bot1-6-1"></td>
<td class="empty" id="bot1-6-2"></td>
<td class="empty" id="bot1-6-3"></td>
<td class="empty" id="bot1-6-4"></td>
<td class="empty" id="bot1-6-5"></td>
<td class="empty" id="bot1-6-6"></td>
<td class="empty" id="bot1-6-7"></td>
<td class="empty" id="bot1-6-8"></td>
<td class="empty" id="bot1-6-9"></td>
</tr>
<tr>
<td>7</td>
<td class="empty" id="bot1-7-0"></td>
<td class="shipOn" id="bot1-7-1"></td>
<td class="shipOn" id="bot1-7-2"></td>
<td class="shipOn" id="bot1-7-3"></td>
<td class="empty" id="bot1-7-4"></td>
<td class="empty" id="bot1-7-5"></td>
<td class="empty" id="bot1-7-6"></td>
<td class="empty" id="bot1-7-7"></td>
<td class="shipOn" id="bot1-7-8"></td>
<td class="empty" id="bot1-7-9"></td>
</tr>
<tr>
<td>8</td>
<td class="empty" id="bot1-8-0"></td>
<td class="empty" id="bot1-8-1"></td>
<td class="empty" id="bot1-8-2"></td>
<td class="empty" id="bot1-8-3"></td>
<td class="empty" id="bot1-8-4"></td>
<td class="empty" id="bot1-8-5"></td>
<td class="empty" id="bot1-8-6"></td>
<td class="empty" id="bot1-8-7"></td>
<td class="shipOn" id="bot1-8-8"></td>
<td class="empty" id="bot1-8-9"></td>
</tr>
<tr>
<td>9</td>
<td class="empty" id="bot1-9-0"></td>
<td class="empty" id="bot1-9-1"></td>
<td class="empty" id="bot1-9-2"></td>
<td class="empty" id="bot1-9-3"></td>
<td class="empty" id="bot1-9-4"></td>
<td class="empty" id="bot1-9-5"></td>
<td class="empty" id="bot1-9-6"></td>
<td class="empty" id="bot1-9-7"></td>
<td class="empty" id="bot1-9-8"></td>
<td class="empty" id="bot1-9-9"></td>
</tr>
</table>
2015-12-27 16:53:58 +01:00
<h3>During the fight</h3>
<p>
Examples of parameters sent by the arena.
</p>
<h4>First round (your_strikes and his_strikes are empty)</h4>
<pre>
[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] => []
</pre>
2015-12-27 16:53:58 +01:00
<h4>Second round</h4>
<pre>
[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":""}]
</pre>
2015-12-27 16:53:58 +01:00
<h4>Third round</h4>
<pre>
[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":""}]
</pre>
2015-12-27 16:53:58 +01:00
<h4>You simply need to return the address of the box where you want to shoot in the form of x,y</h4>
<pre>
2015-12-27 16:53:58 +01:00
6,9
</pre>
2015-12-27 16:53:58 +01:00
<p>
To shoot on the coordinates x=6 y=9
</p>