Download the PHP package p-chess/chess without Composer
On this page you can find all versions of the php package p-chess/chess. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download p-chess/chess
More information about p-chess/chess
Files in p-chess/chess
Package chess
Short Description A PHP chess library that is used for chess move generation/validation, piece placement/movement, and check/checkmate/stalemate detection
License MIT
Informations about the package chess
Chess
Chess 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, forked from ryanhs/chess.php
Installation
use composer with composer require p-chess/chess
or put in your composer.json
Example Code
The code below plays a complete game of chess ... randomly.
Supported output formats
ASCII
Pieces are displayed with corresponding codes (e.g. "p" for pawn, "q" for queen, etc.).
Unicode
Pieces are displayed like in the example above.
PNG Image
Pieces are displayed inside a png image.
See dedicated documentation for a detailed instructions.
HTML
Pieces are displayed inside an HTML table.
See dedicated documentation for a detailed instructions.
Performance
There 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 |
Other documentation
All classes are documented in the docs directory.
All versions of chess with dependencies
ext-ctype Version *
ext-json Version *