Move Number Indication in PGN Export Format

Discussion of chess software programming and technical issues.

Moderator: Ras

tpetzke
Posts: 686
Joined: Thu Mar 03, 2011 4:57 pm
Location: Germany

Move Number Indication in PGN Export Format

Post by tpetzke »

I'm currently working on a PGN writer and came across a problem in the PGN specification regarding the move number indication. The specification is pretty clear. If there is a comment or annotation before the black move the move number is repeated.
A black move element has a preceding move number indication only in two cases: first, if there is intervening annotation or commentary between the black move and the previous white move; and second, if there is no previous white move in the special case where a game starts from a position where Black is the active player.
But both Arena and cutechess-cli produce PGNs that just give the black move without repeating the move number after a comment.

Code: Select all

13. Qc2 {-0.29/11 0.14s} O-O {+0.08/11 0.14s} 14. b4 {-0.26/11 0.14s} Ne6 {+0.55/11 0.13s} 
Is this still valid PGN or just accepted practice ?
Thomas...

=======
http://macechess.blogspot.com - iCE Chess Engine
User avatar
hgm
Posts: 28519
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Move Number Indication in PGN Export Format

Post by hgm »

Well, Win/XBoard is also guilty of such non-compliance with the PGN standard. But actually I consider the format as you show above superior over orthodox PGN, so I have no intention to 'fix' it. The standard was designed based on the assumption that comments would be long sentences of text, and after that having a reminder of the moe number make sense. Engine 'score/depth comments', however, are sufficiently short to not cause any confusion, and repeating the move number would just create an annoying distance between the moves, and bloat the file.

So I think it is good to make an exception for these score-depth comments, and just consider them an extension of the standard, different from normal comments. Which just happen to be disguised as comments to enhance backward compatability. As several GUIs all do this, it has become sort of a de-facto standard.
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: Move Number Indication in PGN Export Format

Post by sje »

The rationale behind the Black move number display is related to the need for human readability of the move text items. Obviously, importing programs should use move number items only for internal verification and consistency checking.

At the time more than two decades ago, there was a reason behind the definition of the export format -- the idea that a given game have exactly one canonical external ASCII representation. This would make it easy to compare games for equality by use of simple string comparison, something which could be done quickly by the hardware of the day.

Well, there are better ways to do this. I really should issue a new PGN Standard which dumps the whole export business. It's on the to-do list.
tpetzke
Posts: 686
Joined: Thu Mar 03, 2011 4:57 pm
Location: Germany

Re: Move Number Indication in PGN Export Format

Post by tpetzke »

Thanks, I'll skip the move number before a Black move after short comments (e.g less than 20 characters) then also.

Thomas..
Thomas...

=======
http://macechess.blogspot.com - iCE Chess Engine
User avatar
stegemma
Posts: 859
Joined: Mon Aug 10, 2009 10:05 pm
Location: Italy
Full name: Stefano Gemma

Re: Move Number Indication in PGN Export Format

Post by stegemma »

Personally i like more the later form, without move numbers before black moves. Reading those numbers it's confusing, to me, because without it you can find easly the white/black move pair and the pgn looks clearest. If you are writing a pgn editor, maybe you must consider to add an option for this detail.
tpetzke
Posts: 686
Joined: Thu Mar 03, 2011 4:57 pm
Location: Germany

Re: Move Number Indication in PGN Export Format

Post by tpetzke »

Hi Stefano,

I also like the format without the black move number more. For import it doesn't matter. I accept here both, I don't even rely on move numbers before white moves. I just wanted to export compliant pgn and the standard seemed to give you no choice. But as it turned out that this part of the standard is widely ignored nowadays I decided to ignore it also and skip the black move number if the comment or annotation in front of it is less than 20 characters (which is the case for auto annotated games where the comment gives info about depth, score and used time. I'm not using this %emt format. This would blow up the comment maybe beyond the 20 chars)

Thomas...
Thomas...

=======
http://macechess.blogspot.com - iCE Chess Engine
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Original rationale

Post by sje »

Original rationale

If i recall correctly, the original rationale for having an explicit Black move number indication following anything other than a White move came from the heritage of printed chess. The idea was to assist a human reader with a gentle reminder of the current full move number.