PHP Command to Check the Syntax of a Chess PGN File

in #utopian-io6 years ago (edited)

Repository

https://github.com/programarivm/pgn-chess

white-chess-pieces.jpg

PGN Chess for PHP 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/pgnsyntax is a new command to check the syntax of a PGN file:

  • pgnsyntax.php

The PR is the continuation of PHP Command That Converts a PGN File into a MySQL Script. It is also an improvement of pgntomysql.php -- now PGN files are converted to MySQL INSERT statements as long as they are syntactically correct.

Example:

php pgnsyntax.php games.pgn
Whoops! Sorry but this is not a valid PGN file.
--------------------------------------------------------
Site: Bhubaneswar IND
Date: 2018.05.28
Round: 5.3
White: Nitin, S
Black: Amonatov, Farrukh
Result: 0-1
WhiteElo: 2432
BlackElo: 2608
EventDate: 2018.05.25
ECO: B90
--------------------------------------------------------
Event: 11. KIIT Elite Open 2018
Site: Bhubaneswar IND
Date: 2018.05.28
Round: 5.17
White: Raahul, V S
Black: Neverov, Valeriy
Result: 1/2-1/2
WhiteElo: 2231
BlackElo: 2496
EventDate: 2018.05.25
ECO: A25
1.foo f5 2.Nc3 Nf6 3.g3 e5 4.Bg2 Nc6 5.e3 Bb4 6.Nge2 O-O 7.O-O d6 8.Nd5 Nxd5 9.cxd5 Ne7 10.d4 Ba5 11.b4 Bb6 12.dxe5 dxe5 13.Qb3 Kh8 14.a4 a6 15. Bb2 Ng6 16.a5 Ba7 17.Qc3 Re8 18.Nf4 Re7 19.Nxg6+ hxg6 20.Rac1 Rb8 21.b5 b6 22.Ba3 Rf7 23.axb6 Rxb6 24.Bc5 e4 25.Bxb6 Bxb6 26.bxa6 Bxa6 27.Rfd1 Rd7 28.Qe5 Rd6 29.Bf1 Bxf1 30.Kxf1 c6 31.Kg2 Kh7 32.h4 cxd5 33.h5 Qd7 34.Rh1 g5 35.Rc8 f4 36.h6 f3+ 37.Kg1 Rxh6 38.Rh8+ Kg6 39.R1xh6+ gxh6 40.Rg8+ Kh5 41.Qf6 Bxe3 42.fxe3 Qc7 43.Qg6+ Kg4 44.Qe6+ Kxg3 45.Rc8 Qa7 46.Qd6+ Kg4 47.Qe6+ Kg3 48.Qd6+ Kg4 1/2-1/2
--------------------------------------------------------
Event: TCh-FRA Top 12 2018
Site: Brest FRA
Date: 2018.05.28
Round: 3.6
White: Eljanov, Pavel
Black: Ragger, Markus
Result: 1/2-1/2
WhiteElo: 2702
BlackElo: 2672
EventDate: 2018.05.26
ECO: A34
1.Nf3 Nf6 20.c4 c5 3.Nc3 d5 4.cxd5 Nxd5 5.e3 e6 6.Bb5+ Bd7 7.Be2 Nc6 8.O-O Be7 9.d4 cxd4 10.Nxd5 exd5 11.exd4 O-O 12.Ne5 Bf5 13.Be3 Bf6 14.Nxc6 bxc6 15.Bd3 Bxd3 16.Qxd3 Qb6 17.Rfc1 Rfe8 18.Qc3 1/2-1/2
--------------------------------------------------------
Please check these games. Do they provide the STR (Seven Tag Roster)? Is the movetext valid?

For further information please visit section 4. Command Line Interface (CLI)

Technology Stack

  • PHP
  • MySQL

Roadmap

At this moment the project is in a position to start loading thousands and thousands of chess games into a database for further processing.

Would you help make this library better?

Contributions are welcome.

  • Feel free to send a pull request
  • Drop an email at [email protected] with the subject "PGN Chess Contributions"
  • Leave me a comment on Twitter
  • Say hello on Google+

Many thanks.

GitHub Account

https://github.com/programarivm

Sort:  

Thank you for your contribution. In your single commit, you have changed 47 files with 40,736 additions and 247 deletions, it's better to divide your work across multiple commits. Also all the generated files, which are not useful for the app can be written in the .gitignore file.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

Hi @codingdefined, thanks for the review.

Yep, it is better to divide the work across multiple commits. Let me just note that I am squash merging my new features as it is shown in this example: Feature/pgnsyntax (#3)

Is that okay? :) I'd like to squash merge the branches to keep the history of the project a bit more concise.

On the other hand, here is the reason behind so many additions. I just added a few sample PGN files for testing purposes, and those ones contain thousands of lines -- games-02.pgn is an example having 10004 lines.

Thank you for your review, @codingdefined!

So far this week you've reviewed 11 contributions. Keep up the good work!

Hey @programarivm
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Hi @programarivm! We are @steem-ua, a new Steem dApp, computing UserAuthority for all accounts on Steem. We are currently in test modus upvoting quality Utopian-io contributions! Nice work!

You have a minor misspelling in the following sentence:

At this moment the project is in a position to start loading thousands and thousands of chess games into a database for futher processing.
It should be further instead of futher.

Hi @grammarnazi, thanks for proofreading my post.