connectFour/connectfou
This commit is contained in:
parent
a8f84a71d9
commit
4bf4042624
|
@ -222,7 +222,7 @@ function play(player){
|
||||||
var arrToSend= {
|
var arrToSend= {
|
||||||
"game-id": "" + gameId,
|
"game-id": "" + gameId,
|
||||||
"action" : "play-turn",
|
"action" : "play-turn",
|
||||||
"game" : "connectFour",
|
"game" : "connectfour",
|
||||||
"players" : 2,
|
"players" : 2,
|
||||||
"board" : board,
|
"board" : board,
|
||||||
"you" : symbol,
|
"you" : symbol,
|
||||||
|
@ -301,9 +301,9 @@ function startGame(){
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open("POST", document.getElementById('url' + p).value, false);
|
xhr.open("POST", document.getElementById('url' + p).value, false);
|
||||||
xhr.setRequestHeader("Content-Type", "application/json");
|
xhr.setRequestHeader("Content-Type", "application/json");
|
||||||
xhr.send(' {"game-id":"' + gameId + '","action":"init","game":"connectFour","players":2,"board":"","player-index":' + (p - 1) +'}');
|
xhr.send(' {"game-id":"' + gameId + '","action":"init","game":"connectfour","players":2,"board":"","player-index":' + (p - 1) +'}');
|
||||||
if(xhr.status == 200) {
|
if(xhr.status == 200) {
|
||||||
addLog('Message d\'init envoyé au bot player ' + p + ' {"game-id":"' + gameId + '","action":"init","game":"connectFour","players":2,"board":"","player-index":' + (p - 1) +'} <br/> il a répondu ' + xhr.responseText );
|
addLog('Message d\'init envoyé au bot player ' + p + ' {"game-id":"' + gameId + '","action":"init","game":"connectfour","players":2,"board":"","player-index":' + (p - 1) +'} <br/> il a répondu ' + xhr.responseText );
|
||||||
}else{
|
}else{
|
||||||
addLog('player ' + p + ' n est pas joignable ' + xhr.status);
|
addLog('player ' + p + ' n est pas joignable ' + xhr.status);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -54,7 +54,7 @@ switch ($_POST['act']){
|
||||||
$params[$player]=array(
|
$params[$player]=array(
|
||||||
'game-id' => $_SESSION['matchId'],
|
'game-id' => $_SESSION['matchId'],
|
||||||
'action' => 'init',
|
'action' => 'init',
|
||||||
'game' => 'connectFou',
|
'game' => 'connectfour',
|
||||||
'players' => 2,
|
'players' => 2,
|
||||||
'board' => '',
|
'board' => '',
|
||||||
'player-index' => $player
|
'player-index' => $player
|
||||||
|
@ -108,7 +108,7 @@ switch ($_POST['act']){
|
||||||
$postDatas=array(
|
$postDatas=array(
|
||||||
'game-id' => $_SESSION['matchId'],
|
'game-id' => $_SESSION['matchId'],
|
||||||
'action' => 'play-turn',
|
'action' => 'play-turn',
|
||||||
'game' => 'connectFour',
|
'game' => 'connectfour',
|
||||||
'players' => 2,
|
'players' => 2,
|
||||||
'opponent' => $opponentName,
|
'opponent' => $opponentName,
|
||||||
'you' => $you,
|
'you' => $you,
|
||||||
|
|
|
@ -10,12 +10,12 @@
|
||||||
<p>Your bot responds with a JSON array.</p>
|
<p>Your bot responds with a JSON array.</p>
|
||||||
<h3>Message initating the game</h3>
|
<h3>Message initating the game</h3>
|
||||||
BotsArena sends:
|
BotsArena sends:
|
||||||
<pre>{"game-id":"1126","action":"init","game":"connectFour","players":2,"board":"","player-index":0}</pre>
|
<pre>{"game-id":"1126","action":"init","game":"connectfour","players":2,"board":"","player-index":0}</pre>
|
||||||
<p>Explanation of each parameters:</p>
|
<p>Explanation of each parameters:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><em>game-id</em> string identifying the party.</li>
|
<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>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>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>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>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>
|
<li><em>player-index</em> int The order of your bot in turns. The first player is 0, second is 2.</li>
|
||||||
|
@ -29,11 +29,11 @@
|
||||||
If your bot returns a blank page at this step (action = init), it will work.</p>
|
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>
|
<h3>Message asking you to play (only one turn) </h3>
|
||||||
<p>The Arena sends as example the following message:</p>
|
<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>
|
<pre>{"game-id":"9916","action":"play-turn","game":"connectfour","players":2,"board":[["","","","","","",""],["","","","","","",""],["","","","","","",""],["","","","","","",""],["","","","","","",""],["","","","","","",""]],"you":"X","player-index":0}</pre>
|
||||||
<ul>
|
<ul>
|
||||||
<li><em>game-id</em> String identifying the party.</li>
|
<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>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 "connectFour".</li>
|
<li><em>game</em> String identifying the game. Always "connectfour".</li>
|
||||||
<li><em>players</em> Int indicating the number of players in the game, still 2 on connect Four.</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>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>you</em> String, Your bot's character on the grid</li>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user