Upgrade to Chess.com Premium!

Python and PGN

I used to be an "IT Professional" (computer programmer with a bit of analysis thrown in) until I was made redundant a few years back and I still enjoy tinkering around with programming on my PC at home. Having recently switched over to Linux, I decided to try to learn the Python programming language that comes packaged with it.

To give myself something to work on, I thought I'd try to write a program to read the PGN format files that chess programs (and chess.com) export and display the chess games. Unfortunately, the specification of the PGN format was written back in 1994 and has a few gaping holes in it so I'm having to try generating some PGN files on-line here to see how chess.com handles them.

The following chess diagram is not, therefore, from an actual game or puzzle...

 

Hmmm... it appears that the chess.com game editor doesn't handle one of the problems so I'll have to see if the help & support people know about the problem.

Comments


  • 22 months ago

    TheWorm

    I heard that the desired approach to reading and writing PGN files is to be forgiving/robust in reading, but to write perfectly.  My friend George Merchant is working on a chess program and he had to write some PGN file reading/writing routines.  His website is www.greenchess.com.  I think if you sent him an email he would probably be glad to share whatever resources he found on the subject.

    Also, a free utility called ChessPad is very adept at reading and writing PGN.  It might be worth downloading it to see how it handles different things.

    p.s.  Nice job with the Pak Protector for your avatar.

Back to Top

Post your reply: