Recommend this page to a friend! |
Classes of Massimiliano Arione | PHP Chess Engine | README.md | Download |
|
DownloadChessChess 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 started as a port of chess.js for php, froked from ryanhs/chess.php Installationuse composer with
Example CodeThe code below plays a complete game of chess ... randomly.
Supported output formatsASCIIPieces are displayed with corresponding codes (e.g. "p" for pawn, "q" for queen, etc.).
UnicodePieces are displayed like in the example above.
PNG ImagePieces are displayed inside a png image.
<img src="https://user-images.githubusercontent.com/179866/112304837-411be280-8c9e-11eb-8333-c2489f9bef05.png"> See dedicated documentation for a detailed instructions. PerformanceThere is still a lot to do in this topic. akondas/php-grandmaster is a good place to start experiment ;) Chess::move()| iteration | mean | comment | | :-------: | :---: | ------- | | 1 | 548.819?s | initial | | 2 | 447.973?s | replace fen with json_encode in history position (inThreefoldRepetition cache) | 3 | 340.375?s | replace fen with json_encode in generateMoves | 4 | 333.145?s | add boardHash calculation on make/undo move | 5 | 25.917?s | :fire: add cache for moveToSAN method |