A chess library for PHP.
Via composer:
$ composer require chesslablab/php-chess
Read the latest docs here.
PHP Chess is being used on Redux Chess, which is a React chessboard connected to a PHP Chess Server. Check out this demo.
Please note the sandbox server might not be up and running all the time.
use Chess\Game;
$game = new Game();
$game->play('w', 'e4');
$game->play('b', 'e5');The call to the $game->play method returns true or false depending on whether or not a chess move can be run on the board.
Pass the Game::MODE_AI parameter when instantiating a $game:
$game = new Game(Game::MODE_AI);
$game->play('w', 'e4');
$game->play('b', $game->response());
$game->play('w', 'e5');
$game->play('b', $game->response());The AIs are stored in the model folder. The default is a1.model, if you want to play with a different AI pass it as a second parameter to the Chess\Game constructor:
$game = new Game(Game::MODE_AI, 'a2.model');
$game->play('w', 'e4');
$game->play('b', $game->response());
$game->play('w', 'e5');
$game->play('b', $game->response());The GNU General Public License.
See the contributing guidelines.
Happy learning and coding! Thank you, and keep it up.
For further information you're invited to read my learning journey:
- Demystifying AI Through a Human-Like Chess Engine
- Two Things That My AI Project Required
- What Are Some Healthy Tips to Reduce Cognitive Load?
- How to Take Normalized Heuristic Pictures
- Equilibrium, Yin-Yang Chess
- Adding Classes to a SOLID Codebase Without Breaking Anything Else
- Preparing a Dataset for Machine Learning With PHP
- Converting a FEN Chess Position Into a PGN Move
- A React Chessboard with Redux and Hooks in Few Lines
- How to Test a Local React NPM Package With Ease
- TDDing a React App With Jest the Easy Way
- How to Test React Components With Joy
- My First Integration Test in a Redux Hooked App
- Creating a Local WebSocket Server With TLS/SSL Is Easy as Pie
- A Simple Example of SSL/TLS WebSocket With ReactPHP and Ratchet
- Newbie Tutorial on How to Rate-Limit a WebSocket Server
- Visualizing Chess Openings Before MLP Classification