/**
  * @param string $question
  * @return bool
  */
 protected function getBooleanAnswer($question)
 {
     $msg = sprintf("%s (y/n)  ", $question);
     $this->ioService->printMessageLine($msg);
     $answer = $this->ioService->fetchInput();
     if (preg_match('/^[yY]/', $answer)) {
         return true;
     }
     return false;
 }
 /**
  * @param Game $game
  * @return array (column, row)
  */
 public function getMove(Game $game)
 {
     if ($game->hasEmptyBoard()) {
         /*
          * If the board is empty, instead of calculating the field to mark,
          * we select it by random.
          *
          * We can do this, because it never worsens this game's result for
          * the player: a computer player will still draw with another computer
          * player, and not lose with a human player.
          *
          * We want to do this, because it's quicker than calculating the move.
          */
         list($column, $row) = $game->getRandomBoardCoordinates();
     } else {
         list($column, $row) = $this->getMiniMaxMove($game);
     }
     $this->ioService->printMessage(sprintf("%s %s\n", $column, $row));
     return [$column, $row];
 }
 /**
  * @param Game   $game
  * @return array (column, row)
  */
 public function getMove(Game $game)
 {
     $move = $this->ioService->fetchInput();
     $coordinates = explode(' ', $move);
     return [$coordinates[0], $coordinates[1]];
 }