From aced31b12c38ca8d349f129712cccd66db9f7dfa Mon Sep 17 00:00:00 2001 From: Gnieark Date: Mon, 25 Jul 2016 18:38:48 +0200 Subject: [PATCH] some fixes --- countBattles.txt | 2 +- src/arenas/tron/Trail.php | 17 +++++++++-------- src/arenas/tron/TronGame.php | 7 +++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/countBattles.txt b/countBattles.txt index 7e4fd5e..7157ddd 100644 --- a/countBattles.txt +++ b/countBattles.txt @@ -1 +1 @@ -1559 \ No newline at end of file +1579 \ No newline at end of file diff --git a/src/arenas/tron/Trail.php b/src/arenas/tron/Trail.php index c740b36..8150eb2 100644 --- a/src/arenas/tron/Trail.php +++ b/src/arenas/tron/Trail.php @@ -34,20 +34,21 @@ class Trail { $this->trail->push($value); } public function __toString(){ - $arr = ""; - foreach($this->trail as $value) { - $arr[] = $value; + return json_encode($this->getTrailAsArray()); + } + 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) { foreach($this->trail as $value) { - if($value == $searchedValue) return TRUE; + if($value == $searchedValue) return true; } - return FALSE; + return false; } public static function kind($var) { diff --git a/src/arenas/tron/TronGame.php b/src/arenas/tron/TronGame.php index 9a10f67..e186945 100644 --- a/src/arenas/tron/TronGame.php +++ b/src/arenas/tron/TronGame.php @@ -73,9 +73,8 @@ class TronGame //return all trails for draw svg $trailsArr = array(); foreach($this->bots as $bot){ - $trailsArr[] = $bot->trail; + $trailsArr[] = $bot->trail->getTrailAsArray(); } - //echo json_encode($trailsArr); return json_encode($trailsArr); } public function new_lap(){ @@ -105,13 +104,13 @@ class TronGame } $responses = $this->get_multi_IAS_Responses($urls,$paramsToSend); - print_r($responses); - //grow bots'tails for ($botCount = 0; $botCount < $nbeBots; $botCount++){ if ($this->bots[$botCount]->isAlive){ + $dir = Direction::make($responses[$botCount]['responseArr']['play']); + $lastsCells[$botCount] = $this->bots[$botCount]->grow($dir); } }