Exemple #1
0
 /**
  * Get best line
  *
  * @param $type
  */
 protected function getWinLine($type)
 {
     $oppositeType = Cell::getOppositeType($type);
     if ($this->winCounts[$type] < $this->winCounts[$oppositeType]) {
         return $this->winLines[$oppositeType];
     } else {
         return $this->winLines[$type];
     }
 }
Exemple #2
0
 /**
  * Construct
  *
  * @param $strategy
  * @param $sideCount
  * @param $myType
  * @param int $winCount
  */
 public function __construct($strategy, $sideCount, $myType, $winCount = 0)
 {
     if (!in_array($myType, array(Cell::TIC, Cell::TAC))) {
         throw ExceptionFactory::wrongCellException($myType);
     }
     if (!in_array($sideCount, Board::$availableSideCount)) {
         throw ExceptionFactory::runtime("Wrong side number");
     }
     if ($winCount > $sideCount) {
         throw ExceptionFactory::runtime("winCount should be less oq equal than sideCount");
     }
     $this->strategy = $this->getStrategyManager()->getByName($strategy);
     $this->board = new Board($sideCount, $winCount);
     $this->myType = $myType;
     $this->oppositeType = Cell::getOppositeType($myType);
 }