private function countFilledFields(GameState $state) : int { $count = 0; for ($row = 0; $row < 3; $row++) { for ($col = 0; $col < 3; $col++) { if ($state->getField($row, $col) != Player::NONE()) { $count++; } } } return $count; }
/** * @return Decision[] */ public function getDecisions() : array { if ($this->win($this->turn) || $this->lose($this->turn)) { return []; } $decisions = []; foreach ($this->board as $row => $rowValues) { foreach ($rowValues as $col => $fieldValue) { if ($fieldValue->equals(Player::NONE())) { $decisions[] = new Decision($row, $col); } } } return $decisions; }