PHPCheckMatePHP棋类框架

联合创作 · 2023-09-30 11:44

phpcheckmate 是一个用 PHP 编写的棋类框架,可进行棋子移动和验证,并可悔棋。

示例代码:

$game = new Game();
$game
->make_move("e2", "e3");
$game
->make_move("f7", "f6");
$game
->make_move("d2", "d3");
$game
->make_move("g7", "g5");
$game
->make_move("d1", "h5");
var_dump
($game->player_checkmated("black")); //true #Player2 checkmated
var_dump
($game->result()); //1 #Game is over

$game
->take_back_move(); #Take back last move

var_dump
($game->player_checkmated("black")); //false #Player2 NOT checkmated
var_dump
($game->result()); // false #Player2 can still move its king
$game
->make_move("d1", "h5");
var_dump
($game->player_checkmated("black")); //true #Player2 checkmated
浏览 9
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报