phpcheckmate 是一个用 PHP 编写的棋类框架,可进行棋子移动和验证,并可悔棋。
示例代码:
$game=newGame();$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#Player2checkmatedvar_dump($game->result());//1#Gameisover$game->take_back_move();#Takebacklastmovevar_dump($game->player_checkmated("black"));//false#Player2NOTcheckmatedvar_dump($game->result());//false#Player2canstillmoveitsking$game->make_move("d1","h5");var_dump($game->player_checkmated("black"));//true#Player2checkmated
评论