dev-master
9999999-devA Tic Tac Toe Game
MIT
The Requires
- php >=5.5.9
The Development Requires
by Robert Asproniu
1.0.1
1.0.1.0A Tic Tac Toe Game
MIT
The Requires
- php >=5.5.9
The Development Requires
by Robert Asproniu
Wallogit.com
2017 © Pedro Peláez
A Tic Tac Toe Game
A PHP Tic Tac Toe Game package with AI included, (*1)
for installing just type:, (*2)
You can install the library via Composer, or by downloading it directly on GitHub., (*3)
Set up a Composer project, then run the following command:, (*4)
php composer.phar require robertasproniu/tic-tac-toe-agent
## Basic usage To create a game instance, use: ```php <?php require_once DIR . '/vendor/autoload.php'; // Composer // OR require_once DIR . '/src/TicTacToe.php'; // ZIP download, (*5)
use \TicTacToeAgent\TicTacToe; use \TicTacToeAgent\Board;, (*6)
$game = new TicTacToe(new Board()); // Create a new game ``` Now, you have created a new game with a empty board., (*7)
You can see the board by using the getBoard() method:
php
print_r( $game->getBoard() );, (*8)
Also you can set players symbols by accessing setPlayers() method:
php
$game->setPlayers(['X', 'O']);, (*9)
For getting recommended move for a player you need to pass board and player symbol
by using makeMove(array $board, $player ) method:
```php
$move = $game->makeMove(array_fill(0, 9, null), 'X'); // board can be multidimensional array too, (*10)
print_r($move); // [2,0,'X'] if available position else [];, (*11)
```, (*12)
A Tic Tac Toe Game
MIT
A Tic Tac Toe Game
MIT