This commit is contained in:
gnieark 2016-06-08 21:01:18 +02:00
parent 014be910d4
commit 7038797ff2
2 changed files with 66 additions and 36 deletions

View File

@ -1,37 +1,46 @@
<h2>Functioning of duels for battle four</h2>
<p>Your program does not have to manage a whole part of noughts and crosses, just one lap</p>
<h3>Connect four's wire rack</h3>
<h1>Functioning of duels for connect four</h1>
<h3>The board</h3>
<ul>
<li>weight: 7 cases</li>
<li>height: 6 cases</li>
<li>witdh: 7 cells</li>
<li>height: 6 cells</li>
</ul>
</p>
<h3>Request Arena -> your bot</h3>
<p>The arbitrator program (the arena) build a request with POST parameters as follow :</p>
<h2>requests from BotsArena to your bot</h2>
<p>To talk, botsarena (the server hosting botsarena) execute a POST request on your bot's http(s) server with the json as body</p>
<p>Your bot responds with a JSON array</p>
<h3>Message initating the game</h3>
BotsArena sends:
<pre>{"game-id":"1126","action":"init","game":"connectFour","players":2,"board":"","player-index":0}</pre>
<p>Explanation of each parameters:</p>
<ul>
<li><em>game-id</em> string identifying the party.</li>
<li><em>action</em> string identifying the phase, <em>init</em> at this step <em>play-turn</em> at the next step.</li>
<li><em>game</em> string identifying the game. Always "connectFour". it can be used if you give a single URL for multiple bots.</li>
<li><em>players</em> Int indicating the number of players in the game, still 2 on Connect Four.</li>
<li><em>board</em> Empty or unused at this step, see next chapter.</li>
<li><em>player-index</em> int The order of your bot in turns. The first player is 0, second is 2.</li>
</ul>
<p>Your bot should return his name JSON format:</p>
<pre>
{"name":"botName"}
</pre>
<table class="tabledoc">
<tr><th>name</th><th>value</th></tr>
<tr>
<td>game</td>
<td>
String, always "connectFour".<br/>
Can be usefull if you use the same URL for play to others 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>you</td><td>your symbol in the grid</td></tr>
<tr><td>grid</td><td>String, representing an array in JSON format. this is the wire.<br/>
the first seven values are the bottom horizontal line.<br/>
Exemple:<br/>
<p>The arena currently does not check this response, the init step was included to ensure compatibility with <a href="https://github.com/moul/bolosseum"> Bolosseum </a> .
If your bot returns a blank page at this step (action = init), it will work.</p>
<h3>Message asking you to play (only one turn) </h3>
<p>The Arena sends as example the following message:</p>
<pre>{"game-id":"9916","action":"play-turn","game":"connectFour","players":2,"board":[["","","","","","",""],["","","","","","",""],["","","","","","",""],["","","","","","",""],["","","","","","",""],["","","","","","",""]],"you":"X","player-index":0}</pre>
<ul>
<li><em>game-id</em> String identifying the party.</li>
<li><em>action</em> String identifying the phase, <em>play-turn</em> now, you have to play.</li>
<li><em>game</em> String identifying the game. Always "tictactoe".</li>
<li><em>players</em> Int indicating the number of players in the game, still 2 on connect Four.</li>
<li><em>board</em> The map, i'll explain it at next chapter</li>
<li><em>you</em> String, Your bot's character on the grid</li>
<li><em>player-index</em> Int The order of your bot in turns. The first player is 0, second is 2.</li>
</ul>
<h4>The map</h4>
<p> It is represented by a sub-array, on the "board" parameter.<br/>Exemple:</p>
<pre>
[["","","","X","0","",""],
["","","","X","","",""],
@ -40,9 +49,30 @@ It will serve you if your AI makes statistics on games.
["","","","","","",""],
["","","","","","",""]]
</pre>
<p>Visually, the connect 4 's plate is reversed. The line with index zero (top in the above excerpt) represents the bottom line.</p>
<h3>Your bot response</h3>
</td></tr>
</table>
<p>JSON format, Only one digit that indicate column you want to play. 0 to 6.</p>
<pre>
{"play":"3"}
</pre>
<p>For play in column three. <br/>
<h3>what return your bot</h3>
<p>only one char: 0,1,2,3,4,5 or 6 that indicates the column you want to play</p>
Obviously the arena respects Newton's laws and place your pawn in the first free space of the column ( starting at index 0 )</p>
<h2> Tools for developing and testing your bot </h2>
<p> To help you on how to manage communications between the bot and the arena, please take a look in the <a href = "https://github.com/gnieark/IAS/blob/master/StupidIAconnectFour.php"> source PHP stupidIA </a>. <p>
<h3> <a href="/testBotScripts/connectfour.html"> Script Botsarena </a> </h3>
<p> This small html + javascript page will allow you to test and debug on your bot. <br/> It will allow you to test your boot via its URL, against himself, a human or stupidIA. <br/> Once ready, Express Sign your bot in the arena. </ p>
<p> By default, browsers do not allow javascript to make Cross domain queries. It is a browser security. So there are three options: </ p>
<ul> <li> You add to your bot <a href="https://www.qwant.com/?q=allow%20cross%20domain%20query%20http%20header&t=all"> headers than allow for CORS </a> field. </li>
<li> More simple, you download the page (right click, save target as) and put it in your bot VHOST time tests. All the code (html, css and javascript) is included in the page without external resource, in order that it can be easily downloaded and used. </li>
<li> You use a web browser that supports JavaScript and allows cross domain queries. <a href="https://www.thepolyglotdeveloper.com/2014/08/bypass-cors-errors-testing-apis-locally/"> It seems possible </a>. </ li>
</ul>
<p> This problem does not arise at the arena once your bot will be registered. Because in that case, it is the requests to the bot, not a browser. </p>
<h3> <a href="https://github.com/moul/bolosseum"> Bolosseum </a> </h3>
<p> You will find command line tools to test and debug your bot on github project Bolosseum of @moul. </p>
<h2> Bringing your bot in this arena </h2>
<p> The registration form your bot is on the site's home page. </p>

View File

@ -4,7 +4,7 @@
<li>largeur: 7 cases</li>
<li>hauteur: 6 cases</li>
</ul>
</p>
<h2>Communications entre l'arène et votre bot</h2>
<p>Pour communiquer, l'arène (le serveur hébergeant botsarena) fait des requetes http(s) de type POST vers les bots. Le message est dans le corps de la requête au format JSON.</p>
@ -42,7 +42,7 @@
</ul>
<h4>la map</h4>
<p>Elle est contenue dans le champs board du message JSON.C'est un tableau à deux dimmensions au format JSON vous indiquant l'état de la grille.<br/>
Exemple:<br/>
Exemple:</p>
<pre>
[["","","","X","0","",""],
["","","","X","","",""],