Tron down to 100X100, My CPU is happy

This commit is contained in:
Gnieark 2016-11-29 18:51:32 +01:00
parent aa48d68c2a
commit 8355a75c99
5 changed files with 9 additions and 9 deletions

View File

@ -1,7 +1,7 @@
<?php <?php
class Coords{ class Coords{
private static $min = 0; private static $min = 0;
private static $max = 999; private static $max = 99;
public $x; public $x;
public $y; public $y;

View File

@ -232,8 +232,8 @@ class TronGame
foreach($botsInfos as $bot){ foreach($botsInfos as $bot){
//find a random start position //find a random start position
do{ do{
$x = rand(1,999); $x = rand(1,99);
$y = rand(1,999); $y = rand(1,99);
}while(in_array($x.",".$y,$positions)); }while(in_array($x.",".$y,$positions));
$positions[] = $x.",".$y; $positions[] = $x.",".$y;

View File

@ -34,8 +34,8 @@
<p>The game ends when there are less than two snakes left</p> <p>The game ends when there are less than two snakes left</p>
<h3>Grid</h3> <h3>Grid</h3>
<ul> <ul>
<li>width: 1000 cells</li> <li>width: 100 cells</li>
<li>Height: 1000 cells</li> <li>Height: 100 cells</li>
</ul> </ul>
<h3>Communications between the arena and the bots</h3> <h3>Communications between the arena and the bots</h3>

View File

@ -34,8 +34,8 @@
<p>Le jeu prend fin lorsqu'il reste moins de deux serpents.</p> <p>Le jeu prend fin lorsqu'il reste moins de deux serpents.</p>
<h3>La grille</h3> <h3>La grille</h3>
<ul> <ul>
<li>largeur: 1000 cases</li> <li>largeur: 100 cases</li>
<li>hauteur: 1000 cases</li> <li>hauteur: 100 cases</li>
</ul> </ul>
<h3>Communications entre l'arène et les bots</h3> <h3>Communications entre l'arène et les bots</h3>

View File

@ -90,7 +90,7 @@ function drawMap(map){
for (var botId in map){ for (var botId in map){
if(typeof(map[botId]['x']) != 'undefined'){ //don't draw deads bots if(typeof(map[botId]['x']) != 'undefined'){ //don't draw deads bots
//draw the point //draw the point
var rect=createElemNS('rect',{'x':map[botId]['x'],'y':map[botId]['y'],'width':'2','height':'2','style':'fill:' + botsColor[botId] + ';'}); var rect=createElemNS('rect',{'x':map[botId]['x'],'y':map[botId]['y'],'width':'1','height':'1','style':'fill:' + botsColor[botId] + ';'});
document.getElementById('map').appendChild(rect); document.getElementById('map').appendChild(rect);
} }
} }
@ -159,7 +159,7 @@ function tron(xd_check){
document.getElementById('fightResult').removeChild(document.getElementById('fightResult').firstChild); document.getElementById('fightResult').removeChild(document.getElementById('fightResult').firstChild);
} }
// draw border; // draw border;
var svg = createElemNS('svg',{'id':'map','width':'500','height':'500','viewBox':'0 0 1000 1000'}); var svg = createElemNS('svg',{'id':'map','width':'500','height':'500','viewBox':'0 0 100 100'});
var rect=createElemNS('rect',{'x':'0','y':'0','width':'1000','height':'1000','style':'stroke:#000000; fill:none;'}); var rect=createElemNS('rect',{'x':'0','y':'0','width':'1000','height':'1000','style':'stroke:#000000; fill:none;'});
svg.appendChild(rect); svg.appendChild(rect);
document.getElementById("fightResult").appendChild(svg); document.getElementById("fightResult").appendChild(svg);