uestla/oxer

PHP 实现的简单井字棋

1.0.7 2016-09-25 08:48 UTC

This package is auto-updated.

Last update: 2024-09-11 21:33:30 UTC


README

OXer 是一个没有第三方依赖的 PHP 实现的简单井字棋。

安装

composer require uestla/oxer

使用方法

$game = new OXer\Game(19, 19, 5); // board 19×19, winning length 5

// coordinates are indexed from zero
$game->play(1, 3); // player O
$game->play(4, 5); // player X

// simple API:
$moves = $game->getMoves();
$ended = $game->hasEnded();
$draw = $game->isDraw();
$winner = $game->getWinner();
$line = $game->getWinningLine();

// board can be serialized
$s = OXer\Serializer::serialize($game);

// and unserialized
$game = OXer\Serializer::unserialize($s);

更多详情请查看测试。

祝您玩得开心!:-)