doc
This commit is contained in:
parent
78bbfbcc3b
commit
db1dc561e5
|
@ -1 +1 @@
|
|||
1681
|
||||
1697
|
|
@ -20,7 +20,7 @@ class TronPlayer{
|
|||
public function loose(){
|
||||
$this->isAlive = false;
|
||||
$this->trail->emptyTrail();
|
||||
error_log($this->name." a perdu");
|
||||
//error_log($this->name." a perdu");
|
||||
return false;
|
||||
}
|
||||
public function make($botId, Coords $initialsCoords,$name,$url){
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
# This file is part of botsArena.
|
||||
#
|
||||
# Copyright (C) Gnieark et contributeurs
|
||||
# Copyright (C) Gnieark https://blog-du-grouik.tinad.fr et contributeurs
|
||||
# Licensed under the GPL version 3.0 license.
|
||||
# See LICENSE file or
|
||||
# http://www.gnu.org/licenses/gpl-3.0-standalone.html
|
||||
|
|
|
@ -73,3 +73,72 @@
|
|||
<pre>
|
||||
{"game-id":"1680","action":"play-turn","game":"tron","board":[[[687,110],[687,111],[686,111],[686,110],[686,109],[686,108],[686,107],[685,107],[685,108],[685,109],[684,109],[684,110],[684,111],[684,112],[684,113],[683,113],[682,113],[681,113],[681,114],[681,115],[681,116],[680,116],[680,117],[679,117],[679,116],[679,115],[679,114],[679,113],[679,112],[679,111],[679,110],[679,109],[678,109],[678,108],[677,108],[676,108],[676,107],[676,106],[676,105],[676,104],[676,103],[675,103],[674,103],[674,102],[673,102],[672,102],[672,101],[671,101],[670,101],[669,101],[669,102],[669,103],[669,104],[669,105],[669,106],[669,107],[668,107],[668,108],[668,109],[668,110],[668,111],[668,112],[667,112],[667,111],[667,110],[666,110],[666,109],[666,108],[665,108],[664,108],[664,107],[664,106],[663,106],[663,107],[663,108],[662,108],[661,108],[660,108],[660,107],[659,107],[659,106],[658,106],[657,106],[657,105],[657,104],[656,104],[656,103],[655,103],[655,102],[655,101],[654,101],[654,102],[654,103],[654,104],[653,104],[653,103],[653,102],[653,101],[653,100],[652,100],[651,100],[651,101],[651,102],[651,103],[651,104],[650,104],[650,105],[650,106],[649,106],[649,105],[648,105]],[[100,225],[100,226],[100,227],[100,228],[100,229],[100,230],[100,231],[99,231],[98,231],[98,232],[97,232],[96,232],[96,231],[96,230],[96,229],[96,228],[96,227],[96,226],[96,225],[96,224],[96,223],[95,223],[95,222],[94,222],[94,221],[94,220],[93,220],[92,220],[92,219],[92,218],[92,217],[92,216],[92,215],[91,215],[91,214],[90,214],[89,214],[89,213],[89,212],[88,212],[88,213],[88,214],[87,214],[87,213],[86,213],[86,214],[86,215],[85,215],[85,214],[84,214],[84,215],[83,215],[83,216],[83,217],[82,217],[82,216],[81,216],[81,215],[80,215],[80,216],[79,216],[79,215],[79,214],[78,214],[77,214],[77,213],[77,212],[76,212],[75,212],[75,211],[75,210],[75,209],[74,209],[74,210],[74,211],[73,211],[73,210],[72,210],[72,209],[71,209],[71,210],[70,210],[70,209],[69,209],[68,209],[68,210],[68,211],[67,211],[67,210],[67,209],[67,208],[66,208],[66,207],[66,206],[66,205],[66,204],[66,203],[65,203],[65,204],[64,204],[64,203],[63,203],[63,204],[63,205],[63,206],[62,206],[61,206],[61,207],[60,207],[60,208],[59,208]]],"player-index":0,"players":2}
|
||||
</pre>
|
||||
<p>Les champs suivants sont les mêmes qu'au paragraphe précédent:</p>
|
||||
<ul>
|
||||
<li><em>game-id</em></li>
|
||||
<li><em>game</em></li>
|
||||
<li><em>players</em></li>
|
||||
<li><em>player-index</em></li>
|
||||
</ul>
|
||||
|
||||
Les champs qui différent sont:
|
||||
<ul>
|
||||
<li><em>action</em>String, est toujours "play-turn" à cette étape</li>
|
||||
<li><em>board</em>Je vous explique ça au chapitre suivant.</li>
|
||||
</ul>
|
||||
<h4>La Carte (board)</h4>
|
||||
<p>Elle est repésentée dans le champs "board" du JSON envoyé par l'arène. Elle décrit les cases prises par chaque joueur.</p>
|
||||
<p> Elle est composée de plusieurs sous-arrays/sous-objets (en fonction de votre language de programmation). Elle se décompose en sous tableaux de la forme suivante:<p>
|
||||
<ul>
|
||||
<li>Board:
|
||||
<ul>
|
||||
<li>Joueur 1
|
||||
<ul>
|
||||
<li>Case1
|
||||
<ul>
|
||||
<li>coordonée X</li>
|
||||
<li>Coordonée Y</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Case2
|
||||
<ul>
|
||||
<li>coordonée X</li>
|
||||
<li>Coordonée Y</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Joueur 2>
|
||||
<ul>
|
||||
<li>Case1
|
||||
<ul>
|
||||
<li>coordonée X</li>
|
||||
<li>Coordonée Y</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Case2
|
||||
<ul>
|
||||
<li>coordonée X</li>
|
||||
<li>Coordonée Y</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
<li>...</li>
|
||||
<ul>
|
||||
</li>
|
||||
</ul>
|
||||
<p> La représentation JSON est la suivante:</p>
|
||||
|
||||
<p>
|
||||
[<br />
|
||||
[<br />
|
||||
[x1,y1],[x2,y2],[x3,y3]<br />
|
||||
],<br />
|
||||
[<br />
|
||||
(...)<br />
|
||||
]<br />
|
||||
</p>
|
||||
<p>L'ordre des "queues" des serpents dans ce tableau correspond à l'ordre des joueurs. Donc votre serpent est representée par la queue correspondant à player-index (le décompte de player-index commence par 0).</p>
|
||||
<p>L'ordre des couples de coordonnées de chaque bot, est dans le sens queue vers la tête. Les bots grandissent à chaque tour en déplaçant leur tête.</p>
|
||||
|
|
|
@ -84,16 +84,30 @@ function applyInitMessage(req,xd_check){
|
|||
|
||||
|
||||
function drawMap(map){
|
||||
console.log(map);
|
||||
//console.log(map);
|
||||
var botsColor = ['cyan','darkmagenta','darkred','darkslategrey','deeppink','dodgerblue','goldenrod','grey','indigo','lightgreen','mediumslateblue','midnightblue'];
|
||||
|
||||
for (var botId in map){
|
||||
//draw the point
|
||||
var rect=createElemNS('rect',{'x':map[botId]['x'],'y':map[botId]['y'],'width':'2','height':'2','style':'fill:' + botsColor[botId] + ';'});
|
||||
document.getElementById('map').appendChild(rect);
|
||||
if(typeof(map[botId]['x']) != 'undefined'){ //don't draw deads bots
|
||||
//draw the point
|
||||
var rect=createElemNS('rect',{'x':map[botId]['x'],'y':map[botId]['y'],'width':'2','height':'2','style':'fill:' + botsColor[botId] + ';'});
|
||||
document.getElementById('map').appendChild(rect);
|
||||
}
|
||||
}
|
||||
}
|
||||
function delTrail(order){
|
||||
var botsColor = ['cyan','darkmagenta','darkred','darkslategrey','deeppink','dodgerblue','goldenrod','grey','indigo','lightgreen','mediumslateblue','midnightblue'];
|
||||
//on supprime tous les elements ayant la couleur correspndante.
|
||||
|
||||
var container = document.getElementById('map');
|
||||
|
||||
var listNode = container.children;
|
||||
for (var i= 0; i < listNode.length; i++){
|
||||
if( listNode[i].style.fill == botsColor[order] ){
|
||||
container.removeChild(listNode[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
function play(gameId,xd_check){
|
||||
|
||||
var req = new XMLHttpRequest();
|
||||
|
@ -102,6 +116,21 @@ function play(gameId,xd_check){
|
|||
if(req.status == 200) {
|
||||
//addLog(req.responseText);
|
||||
var reponse = JSON.parse(req.responseText);
|
||||
|
||||
//to do Effacer les bots perdants
|
||||
for(var i=0; i < reponse['lap']['loosers'].length; i++){
|
||||
//alert (req.responseText);
|
||||
//return;
|
||||
delTrail(reponse['lap']['loosers'][i]['order']);
|
||||
|
||||
//find the bot name
|
||||
for (var j = 0; j < botsAvailable.length; j ++){
|
||||
if(botsAvailable[j]['id'] == reponse['lap']['loosers'][i]['order']){
|
||||
var botName = botsAvailable[j]['name'];
|
||||
}
|
||||
}
|
||||
addLog("Bot " + reponse['lap']['loosers'][i]['order'] + "id " + reponse['lap']['loosers'][i]['id'] + " Name: " + botName + " a perdu.");
|
||||
}
|
||||
drawMap(reponse['lap']['last_points']);
|
||||
if(reponse['continue'] == '1'){
|
||||
|
||||
|
|
|
@ -7,3 +7,4 @@
|
|||
#configurePlayers fieldset{display: block; width: 100px; float:left;}
|
||||
#logs{display:block;padding-left:10px; height: 200px; overflow-y: scroll;}
|
||||
#logs p em {color: grey; font-size: 70%; test-transform:italic;}
|
||||
code{font-family: monospace;}
|
Loading…
Reference in New Issue
Block a user