public function testGameCreation() { $generator = new Generator(); $game = $generator->createGame(); $this->assertTrue($game instanceof Entities\Game); return $game; }
public function testGetBoard() { $generator = new Generator(); $game = $generator->createGame(); $board = $game->getBoard(); return $board; }
public function setup() { $generator = new Generator(); $this->game = $generator->createGame(); $this->board = $this->game->getBoard(); $this->manipulator = new Manipulator($this->board); }
public function setup() { $generator = new Generator(); $this->game = $generator->createGame(); $this->board = $this->game->getBoard(); $this->manipulator = new TestManipulator($this->game, new ArrayObject()); }
protected function createBoard() { $generator = new Generator(); $game = $generator->createGame(); $board = $game->getBoard(); return $board; }
public function setup() { $generator = new Generator(); $this->game = $generator->createGame(); $this->board = $this->game->getBoard(); $this->manipulator = new TestManipulator($this->game, new \Bundle\LichessBundle\Document\Stack()); }
protected function create() { $generator = new Generator(); $this->game = $generator->createGame(); $this->board = $this->game->getBoard(); $dir = sys_get_temp_dir(); return $this->socket = new Socket($dir); }
public function testBoardCreation() { $generator = new Generator(); $game = $generator->createGame(); $board = $game->getBoard(); $this->assertTrue($board instanceof Board); return $board; }
public function testDiffToMove() { $generator = new Generator(); $game = $generator->createGame(); $manipulator = new Manipulator($game->getBoard()); $forsythe = new Forsythe(); $this->assertEquals(null, $forsythe->diffToMove($game, 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq')); $this->assertEquals('e2 e4', $forsythe->diffToMove($game, 'rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq')); }
public function testGameCreation() { $generator = new Generator(); $game = $generator->createGame(); $this->assertTrue($game instanceof Entities\Game); $this->assertEquals(0, $game->getTurns()); $this->assertEquals(false, $game->getIsStarted()); $this->assertEquals(false, $game->getIsFinished()); return $game; }
function _playWholeGame() { $moves = array('e2 e4', 'd7 d5', 'e4 d5', 'd8 d5', 'b1 c3', 'd5 a5', 'd2 d4', 'c7 c6', 'g1 f3', 'c8 g4', 'c1 f4', 'e7 e6', 'h2 h3', 'g4 f3', 'd1 f3', 'f8 b4', 'f1 e2', 'b8 d7', 'a2 a3', 'e8 c8', 'a3 b4', 'a5 a1', 'e1 d2', 'a1 h1', 'f3 c6', 'b7 c6', 'e2 a6'); $generator = new Generator(); $game = $generator->createGame(); $manipulator = new Manipulator($game->getBoard()); foreach ($moves as $move) { $manipulator->play($move); } }
public function testGameCreationStandard960() { $generator = new Generator(); $game = $generator->createGame(Document\Game::VARIANT_960); $this->assertTrue($game instanceof Document\Game); $this->assertEquals(0, $game->getTurns()); $this->assertEquals(false, $game->getIsStarted()); $this->assertEquals(false, $game->getIsFinished()); return $game; }
/** * Get a game from visual data block * * @return Game **/ protected function createGame($data = null) { $generator = new Generator(); if ($data) { $game = $generator->createGameFromVisualBlock($data); $game->setTurns(20); } else { $game = $generator->createGame(); } $game->setStatus(Game::STARTED); return $game; }
/** * Get a game from visual data block * * @return Game **/ protected function createGame($data = null) { $generator = new Generator(); if ($data) { $game = $generator->createGameFromVisualBlock($data); } else { $game = $generator->createGame(); } $this->analyser = new Analyser($game->getBoard()); $game->setStatus(Game::STARTED); $game->setTurns(30); return $game; }
<?php use Bundle\LichessBundle\Persistence\FilePersistence; use Bundle\LichessBundle\Chess\Generator; require_once __DIR__ . '/bootstrap.php'; require_once __DIR__ . '/../../Persistence/PersistenceInterface.php'; require_once __DIR__ . '/../../Persistence/FilePersistence.php'; $dir = sys_get_temp_dir() . '/lichess'; if (!is_dir($dir)) { mkdir($dir); } $persistence = new FilePersistence($dir); $generator = new Generator(); $game = $generator->createGame(); $hash = $game->getHash(); $file = $persistence->getGameFile($game); $persistence->save($game); $iterations = 1000; $start = microtime(true); for ($it = 0; $it < $iterations; $it++) { $persistence->find($hash); } $time = 1000 * (microtime(true) - $start); printf('%s %d games in %01.2f ms' . "\n", 'Find', $iterations, $time); printf('%01.2f ms per find' . "\n", $time / $iterations); $start = microtime(true); for ($it = 0; $it < $iterations; $it++) { $persistence->save($game); } $time = 1000 * (microtime(true) - $start); printf('%s %d games in %01.2f ms' . "\n", 'Save', $iterations, $time);
protected function createGame() { $generator = new Generator(); $game = $generator->createGame(); return $game; }
/** * Get a game from visual data block * * @return Game **/ protected function createGame($data = null, $blackTurn = false) { $generator = new Generator(); if ($data) { $this->game = $generator->createGameFromVisualBlock($data); } else { $this->game = $generator->createGame(); } $this->game->setStatus(Game::STARTED); $this->game->setTurns($blackTurn ? 11 : 10); $this->analyser = new Analyser($this->game->getBoard()); }