some fixes
This commit is contained in:
parent
8f093f6966
commit
aced31b12c
|
@ -1 +1 @@
|
||||||
1559
|
1579
|
|
@ -34,20 +34,21 @@ class Trail {
|
||||||
$this->trail->push($value);
|
$this->trail->push($value);
|
||||||
}
|
}
|
||||||
public function __toString(){
|
public function __toString(){
|
||||||
$arr = "";
|
return json_encode($this->getTrailAsArray());
|
||||||
foreach($this->trail as $value) {
|
}
|
||||||
$arr[] = $value;
|
public function getTrailAsArray(){
|
||||||
|
$arr = array();
|
||||||
|
foreach($this->trail as $coord) {
|
||||||
|
$arr[] = array($coord->x,$coord->y);
|
||||||
}
|
}
|
||||||
return json_encode($arr);
|
return $arr;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
public function contains($searchedValue) {
|
public function contains($searchedValue) {
|
||||||
foreach($this->trail as $value) {
|
foreach($this->trail as $value) {
|
||||||
if($value == $searchedValue) return TRUE;
|
if($value == $searchedValue) return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function kind($var) {
|
public static function kind($var) {
|
||||||
|
|
|
@ -73,9 +73,8 @@ class TronGame
|
||||||
//return all trails for draw svg
|
//return all trails for draw svg
|
||||||
$trailsArr = array();
|
$trailsArr = array();
|
||||||
foreach($this->bots as $bot){
|
foreach($this->bots as $bot){
|
||||||
$trailsArr[] = $bot->trail;
|
$trailsArr[] = $bot->trail->getTrailAsArray();
|
||||||
}
|
}
|
||||||
//echo json_encode($trailsArr);
|
|
||||||
return json_encode($trailsArr);
|
return json_encode($trailsArr);
|
||||||
}
|
}
|
||||||
public function new_lap(){
|
public function new_lap(){
|
||||||
|
@ -105,13 +104,13 @@ class TronGame
|
||||||
}
|
}
|
||||||
|
|
||||||
$responses = $this->get_multi_IAS_Responses($urls,$paramsToSend);
|
$responses = $this->get_multi_IAS_Responses($urls,$paramsToSend);
|
||||||
|
|
||||||
print_r($responses);
|
print_r($responses);
|
||||||
|
|
||||||
//grow bots'tails
|
//grow bots'tails
|
||||||
for ($botCount = 0; $botCount < $nbeBots; $botCount++){
|
for ($botCount = 0; $botCount < $nbeBots; $botCount++){
|
||||||
if ($this->bots[$botCount]->isAlive){
|
if ($this->bots[$botCount]->isAlive){
|
||||||
|
|
||||||
$dir = Direction::make($responses[$botCount]['responseArr']['play']);
|
$dir = Direction::make($responses[$botCount]['responseArr']['play']);
|
||||||
|
|
||||||
$lastsCells[$botCount] = $this->bots[$botCount]->grow($dir);
|
$lastsCells[$botCount] = $this->bots[$botCount]->grow($dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user