|
|
|
@ -123,6 +123,7 @@ class TronGame
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
|
|
$lastsCells[$botCount] = $this->bots[$botCount]->grow($dir);
|
|
|
|
|
|
|
|
|
|
if($lastsCells[$botCount] === false){
|
|
|
|
|
$loosers[] = $botCount;
|
|
|
|
|
$this->bots[$botCount]->loose();
|
|
|
|
@ -152,7 +153,6 @@ class TronGame
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//loosers list (in order to pass their id)
|
|
|
|
|
$loosersList = array();
|
|
|
|
|
foreach($loosers as $looser){
|
|
|
|
@ -173,6 +173,7 @@ class TronGame
|
|
|
|
|
|
|
|
|
|
$cmh = curl_multi_init();
|
|
|
|
|
for ($i = 0; $i < count($iasUrls); $i++){
|
|
|
|
|
if(isset($postParams[$i])){ //dont use already deads bots
|
|
|
|
|
$data_string = json_encode($postParams[$i]);
|
|
|
|
|
|
|
|
|
|
$ch[$i] = curl_init($iasUrls[$i]);
|
|
|
|
@ -187,6 +188,7 @@ class TronGame
|
|
|
|
|
);
|
|
|
|
|
curl_multi_add_handle($cmh,$ch[$i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//send the requests
|
|
|
|
|
do {
|
|
|
|
@ -195,7 +197,10 @@ class TronGame
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Get results
|
|
|
|
|
|
|
|
|
|
for ($i = 0; $i < count($iasUrls); $i++){
|
|
|
|
|
|
|
|
|
|
if(isset($postParams[$i])){
|
|
|
|
|
// Check for errors
|
|
|
|
|
$curlError = curl_error($ch[$i]);
|
|
|
|
|
if($curlError == "") {
|
|
|
|
@ -216,6 +221,9 @@ class TronGame
|
|
|
|
|
//close
|
|
|
|
|
curl_multi_remove_handle($cmh, $ch[$i]);
|
|
|
|
|
curl_close($ch[$i]);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// Clean up the curl_multi handle
|
|
|
|
|
curl_multi_close($cmh);
|
|
|
|
|