alcalyn/tictactoe

PHP 中另一个 TicTacToe 实现。

1.0.0 2016-02-01 21:34 UTC

This package is not auto-updated.

Last update: 2024-09-20 18:28:48 UTC


README

PHP 中另一个 TicTacToe 实现。

下载

使用 composer

    "alcalyn/tictactoe": "1.0.x",

使用方法

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
*/

查看完整的 TicTacToe 类。

许可证

此库采用 MIT 许可证。