create account

PHP Command to Check the Syntax of a Chess PGN File by programarivm

View this thread on: hive.blogpeakd.comecency.com
· @programarivm · (edited)
$21.91
PHP Command to Check the Syntax of a Chess PGN File
#### Repository
https://github.com/programarivm/pgn-chess

![white-chess-pieces.jpg](https://cdn.steemitimages.com/DQmTM9BF4xn2N3LQRPbH7941eTiA6fUHiJtRsiEEP3x66GV/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](https://github.com/programarivm/pgn-chess/pull/3) 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](https://steemit.com/utopian-io/@programarivm/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)](https://github.com/programarivm/pgn-chess#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 info@programarivm.com with the subject "PGN Chess Contributions"
- Leave me a comment on [Twitter](https://twitter.com/programarivm)
- Say hello on [Google+](https://plus.google.com/+Programarivm)

Many thanks.

#### GitHub Account
https://github.com/programarivm
πŸ‘  , , , , , , , , , , , , , , , ,
properties (23)
authorprogramarivm
permlinkphp-command-to-check-the-syntax-of-a-chess-pgn-file
categoryutopian-io
json_metadata{"tags":["utopian-io","development","php","chess"],"image":["https://cdn.steemitimages.com/DQmTM9BF4xn2N3LQRPbH7941eTiA6fUHiJtRsiEEP3x66GV/white-chess-pieces.jpg"],"links":["https://github.com/programarivm/pgn-chess","https://github.com/programarivm/pgn-chess/pull/3","https://steemit.com/utopian-io/@programarivm/php-command-that-converts-a-pgn-file-into-a-mysql-script","https://github.com/programarivm/pgn-chess#4-command-line-interface-cli","https://twitter.com/programarivm","https://plus.google.com/+Programarivm","https://github.com/programarivm"],"app":"steemit/0.1","format":"markdown"}
created2018-08-19 21:35:30
last_update2018-08-19 21:37:42
depth0
children7
last_payout2018-08-26 21:35:30
cashout_time1969-12-31 23:59:59
total_payout_value16.490 HBD
curator_payout_value5.418 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length3,559
author_reputation2,631,258,794,707
root_title"PHP Command to Check the Syntax of a Chess PGN File"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id68,736,540
net_rshares16,426,212,935,766
author_curate_reward""
vote details (17)
@codingdefined ·
$5.16
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](https://join.utopian.io/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](https://review.utopian.io/result/3/3322213).

---- 
Need help? Write a ticket on https://support.utopian.io/. 
Chat with us on [Discord](https://discord.gg/uTyJkNm). 
[[utopian-moderator]](https://join.utopian.io/)
πŸ‘  , , , , , , , ,
properties (23)
authorcodingdefined
permlinkre-programarivm-php-command-to-check-the-syntax-of-a-chess-pgn-file-20180820t113401462z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"links":["https://join.utopian.io/guidelines","https://review.utopian.io/result/3/3322213","https://support.utopian.io/","https://discord.gg/uTyJkNm","https://join.utopian.io/"],"app":"steemit/0.1"}
created2018-08-20 11:34:00
last_update2018-08-20 11:34:00
depth1
children2
last_payout2018-08-27 11:34:00
cashout_time1969-12-31 23:59:59
total_payout_value3.894 HBD
curator_payout_value1.263 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length773
author_reputation529,662,702,871,277
root_title"PHP Command to Check the Syntax of a Chess PGN File"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id68,793,939
net_rshares3,815,458,463,272
author_curate_reward""
vote details (9)
@programarivm · (edited)
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)](https://github.com/programarivm/pgn-chess/commit/3e2390e1f315918f915d5b674f7606cb6aa3feae)

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](https://github.com/programarivm/pgn-chess/blob/3e2390e1f315918f915d5b674f7606cb6aa3feae/tests/unit/PGN/File/data/games-02.pgn) is an example having 10004 lines.
properties (22)
authorprogramarivm
permlinkre-codingdefined-re-programarivm-php-command-to-check-the-syntax-of-a-chess-pgn-file-20180821t120646828z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"users":["codingdefined"],"links":["https://github.com/programarivm/pgn-chess/commit/3e2390e1f315918f915d5b674f7606cb6aa3feae","https://github.com/programarivm/pgn-chess/blob/3e2390e1f315918f915d5b674f7606cb6aa3feae/tests/unit/PGN/File/data/games-02.pgn"],"app":"steemit/0.1"}
created2018-08-21 12:06:51
last_update2018-08-21 12:08:21
depth2
children0
last_payout2018-08-28 12:06:51
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length768
author_reputation2,631,258,794,707
root_title"PHP Command to Check the Syntax of a Chess PGN File"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id68,906,907
net_rshares0
@utopian-io ·
Thank you for your review, @codingdefined!

So far this week you've reviewed 11 contributions. Keep up the good work!
properties (22)
authorutopian-io
permlinkre-re-programarivm-php-command-to-check-the-syntax-of-a-chess-pgn-file-20180820t113401462z-20180822t194508z
categoryutopian-io
json_metadata"{"app": "beem/0.19.42"}"
created2018-08-22 19:45:09
last_update2018-08-22 19:45:09
depth2
children0
last_payout2018-08-29 19:45:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length117
author_reputation152,955,367,999,756
root_title"PHP Command to Check the Syntax of a Chess PGN File"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id69,049,229
net_rshares0
@grammarnazi ·
Minor Correction
You have a minor misspelling in the following sentence: <blockquote>At this moment the project is in a position to start loading thousands and thousands of chess games into a database for futher processing.</blockquote> It should be <i>further</i> instead of <i>futher</i>.
πŸ‘  
properties (23)
authorgrammarnazi
permlinkre-programarivm-php-command-to-check-the-syntax-of-a-chess-pgn-file-20180819t213513742z
categoryutopian-io
json_metadata{"app":"steemit"}
created2018-08-19 21:35:36
last_update2018-08-19 21:35:36
depth1
children1
last_payout2018-08-26 21:35:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length273
author_reputation-144,064,903,190
root_title"PHP Command to Check the Syntax of a Chess PGN File"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id68,736,548
net_rshares595,425,500
author_curate_reward""
vote details (1)
@programarivm ·
Hi @grammarnazi, thanks for proofreading my post.
properties (22)
authorprogramarivm
permlinkre-grammarnazi-re-programarivm-php-command-to-check-the-syntax-of-a-chess-pgn-file-20180819t213928095z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"users":["grammarnazi"],"app":"steemit/0.1"}
created2018-08-19 21:39:27
last_update2018-08-19 21:39:27
depth2
children0
last_payout2018-08-26 21:39:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length49
author_reputation2,631,258,794,707
root_title"PHP Command to Check the Syntax of a Chess PGN File"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id68,736,805
net_rshares0
@steem-ua ·
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!
πŸ‘  
properties (23)
authorsteem-ua
permlinkre-php-command-to-check-the-syntax-of-a-chess-pgn-file-20180820t122026z
categoryutopian-io
json_metadata"{"app": "beem/0.19.54"}"
created2018-08-20 12:20:27
last_update2018-08-20 12:20:27
depth1
children0
last_payout2018-08-27 12:20:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length189
author_reputation23,214,230,978,060
root_title"PHP Command to Check the Syntax of a Chess PGN File"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id68,797,845
net_rshares607,577,041
author_curate_reward""
vote details (1)
@utopian-io ·
$0.02
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.**

<a href='https://v2.steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1'>Vote for Utopian Witness!</a>
πŸ‘  ,
properties (23)
authorutopian-io
permlinkre-php-command-to-check-the-syntax-of-a-chess-pgn-file-20180821t142008z
categoryutopian-io
json_metadata"{"app": "beem/0.19.42"}"
created2018-08-21 14:20:09
last_update2018-08-21 14:20:09
depth1
children0
last_payout2018-08-28 14:20:09
cashout_time1969-12-31 23:59:59
total_payout_value0.018 HBD
curator_payout_value0.004 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length305
author_reputation152,955,367,999,756
root_title"PHP Command to Check the Syntax of a Chess PGN File"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id68,918,740
net_rshares16,419,921,927
author_curate_reward""
vote details (2)