aglaia-resident / chess.php
Fork of ryanhs/chess.php. chess.php is a PHP chess library that is used for chess move generation/validation, piece placement/movement, and check/checkmate/stalemate detection - basically everything but the AI. NOTE: this is a port of chess.js for php
Requires
- php: >=8.1
Requires (Dev)
- dms/phpunit-arraysubset-asserts: ^0.2.0
- friendsofphp/php-cs-fixer: ^2.15
- johnkary/phpunit-speedtrap: ^3.1
- phpunit/phpunit: ^9
README
This project is a fork of ryanhs/chess.php, which is abandonned. chess.php itself was a port of chess.js. Main changes compared to the original ryanhs project are:
- It is compatible with PHP 8.1.
- PHP Unit has been updated to version 9
- The documentation has been imported right in the project
chess.php is a PHP chess library that is used for chess move generation/validation, piece placement/movement, and check/checkmate/stalemate detection - basically everything but the AI.
NOTE: this is a port of chess.js for php
Installation
composer require aglaia-resident/chess.php
Example Code
The code below plays a complete game of chess ... randomly.
<?php require 'vendor/autoload.php'; use \Ryanhs\Chess\Chess; $chess = new Chess(); while (!$chess->gameOver()) { $moves = $chess->moves(); $move = $moves[mt_rand(0, count($moves) - 1)]; $chess->move($move); } echo $chess->ascii() . PHP_EOL;