Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alcalyn/tictactoe
Another TicTacToe implementation.
https://github.com/alcalyn/tictactoe
Last synced: 4 days ago
JSON representation
Another TicTacToe implementation.
- Host: GitHub
- URL: https://github.com/alcalyn/tictactoe
- Owner: alcalyn
- License: mit
- Created: 2016-02-01T21:01:14.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-02-01T21:38:15.000Z (almost 9 years ago)
- Last Synced: 2024-10-11T13:12:29.240Z (28 days ago)
- Language: PHP
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TicTacToe
Another TicTacToe implementation in PHP.
## Download
With composer:
``` json
"alcalyn/tictactoe": "1.0.x",
```## Usage
``` php
use Alcalyn\TicTacToe\TicTacToe;$grid = new TicTacToe();
$grid->play(1, 1, TicTacToe::X); // X plays middle
$grid->play(0, 2, TicTacToe::O); // O plays bottom left// Is left empty ?
$grid->isEmpty(0, 1);$grid->getCurrentPlayer();
// Returns TicTacToe::X or TicTacToe::O$grid->getWinner();
// Returns TicTacToe::X, TicTacToe::O, TicTacToe::DRAW or null for no winner.$grid->getBrochette();
// Returns the 3-in-a-row if there is (or null), with the numbers of the squares:
// Example: [2, 4, 6]
/*
Grid:
0 1 2
3 4 5
6 7 8
*/
```See the complete [TicTacToe](src/TicTacToe.php) class.
## License
This library is under the [MIT](LICENSE) license.