Repository
https://github.com/programarivm/pgn-chess
PGN Chess is a simple, friendly, and powerful PGN (Portable Game Notation) library for running chess games from within PHP applications. It is a chess board representation that can be used in chess engines, chess applications and chess algorithms.
New Features
Feature/db seed #6 is a new command that searches for valid games in a PGN file and seeds the PGN Chess database accordingly:
db-seed.php
Example:
php db-seed.php Alekhine.pgn
This will search for valid PGN games in the file.
Large files (for example 50MB) may take a few seconds to be inserted into the database.
Do you want to proceed? (Y/N): y
Good! This is a valid PGN file. 3201 games were inserted into the database.
Now, you can get information from a particular player, Elo ranges, FIDE titles, or any other imaginable combination of properties as shown in the following example.
SELECT * FROM games WHERE White LIKE '%Alekhine%' AND Eco='C50';
Remember: the games are syntactically valid.
This cool feature is intended to add knowledge/intelligence to the PGN Chess system in the medium term. For further information please visit section 4. Command Line Interface (CLI)
Technology Stack
- PHP
- PDO
- MySQL
Roadmap
The next thing to do is to write and share an amazing post on how to easily load tons of games into a chess database for multiple purposes! The feedback generated will help to spot bugs and improve the current features.
Who knows, perhaps at some point we could even use PGN Chess to create an open chess database as discussed at Let's create a free, open, chess database. I already shared this roadmap on the Google+ community Chess.
Also, a database seeded with millions of chess games allows to train a machine learning model through a SQL interface as it is described next.
Command line:
php ml-train-naive-bayes.php naive-bayes.txt
PHP code:
use PGN\MachineLearning\NaiveBayesTrainer;
require_once __DIR__ . '/../../vendor/autoload.php';
(new NaiveBayesTrainer($argv[1]))->train('SELECT * FROM games');
Would you help make this library better?
Contributions are welcome.
- Feel free to send a pull request
- Drop an email at info@programarivm.com with the subject "PGN Chess Contributions"
- Leave me a comment on Twitter
- Say hello on Google+
Many thanks.