public static function run($bot)
 {
     global $argv, $argc;
     $ants = new Ants();
     $map_data = array();
     $round = 0;
     if (in_array("--debug", $argv)) {
         $ants->debugFlag = true;
     }
     if (in_array("--visTool", $argv)) {
         $ants->visTool = true;
     }
     if ($ants->debugFlag) {
         unlink($_SERVER['PWD'] . "/debug_ants.log");
     }
     while (true) {
         $current_line = fgets(STDIN, 1024);
         $current_line = trim($current_line);
         if ($current_line === 'ready') {
             $ants->setup($map_data);
             $ants->finishTurn();
             $map_data = array();
         } elseif ($current_line === 'go') {
             $round++;
             $ants->currentTurn = $round;
             $ants->roundStart = microtime(true);
             if ($round == 1) {
                 $bot->doSetup($ants);
             }
             $ants->update($map_data);
             $bot->doTurn($ants);
             $ants->finishTurn();
             $map_data = array();
         } else {
             $map_data[] = $current_line;
         }
     }
 }
Beispiel #2
0
 public static function run($bot)
 {
     $ants = new Ants();
     $map_data = array();
     while (true) {
         $current_line = fgets(STDIN, 1024);
         $current_line = trim($current_line);
         if ($current_line === 'ready') {
             $ants->setup($map_data);
             $ants->finishTurn();
             $map_data = array();
         } elseif ($current_line === 'go') {
             $ants->update($map_data);
             $bot->doTurn($ants);
             $ants->finishTurn();
             $map_data = array();
         } else {
             $map_data[] = $current_line;
         }
     }
 }