Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Comments in PGN files -- Please help (programming question)

Author: Heiner Marxen

Date: 13:13:56 01/30/02

Go up one level in this thread


On January 29, 2002 at 15:05:45, Tim Foden wrote:

>I am in the process of fiddling with a GUI of mine (in the long run up to
>releasing it as a GUI for Green Light).  I am currently trying to figure
>out how to handle comments in PGN.  I want to store the whole PGN tree in my
>program, and allow variation to be played, added, removed, etc.
>
>To be more specific, I want to be able to load a PGN file, and save it again,
>and not lose any of the comment information (including its position).
>
>
>Here is some example PGN (one of Kurt Utzingers great commented games,
>truncated, and with most of the comments stripped out):
>
>[Event "Gromit382_Pharaon261"]
>[Site "Wetzikon"]
>[Date "2002.01.19"]
>[Round "1"]
>[White "Gromit382"]
>[Black "Pharaon 2.61"]
>[Result "1/2-1/2"]
>[ECO "A84"]
>[Annotator "Utzinger,K"]
>[PlyCount "299"]
>[Time Control "40 move/40 min"]
>{Gromit 3.8.2 - Pharaon 2.61, WinBoard 4.2.5 match, 40'/40, P3 650/128, 32 MB
>hash each, ponder=off, 4-men and partly 5-men TB's } 1. d4 d5 2. c4 c6 3.
>Nf3 e6 4. e3 {White last book move} 4... f5 5. Bd3 Nf6 {Black last book move}
>6. Nc3 Be7 7. O-O O-O 8. Bd2 Ne4 9. Be1 Re8 10. Qe2 Nd7 11. a4 Bd6 12. b4 Qf6
>13. b5 Qg6 14. Rc1 Rb8 15. Qd1 Rd8 16. cxd5 exd5 17. Ne2 c5
>{In my opinion a wrong decision that
>leads to a weak isolated d-pawn. But more important is the fact that White now
>finds the opportunity to activate his pieces.} (17... Qh6 18. bxc6 bxc6 19. Ng3
>Nb6 20. Rxc6 Bd7 21. Rc1 Nxa4 {with better play for Black.}) 18. dxc5 Ndxc5 19.
>Bb1 Be6 20. Ned4 Bd7 21. Ba2 Qf7 22. Bb4 b6 23. Ne2 ({Most interesting is} 23.
>Nc6 Bxc6 24. bxc6 Rbc8 25.
>Nd4 {and it is difficult for Black to find a good defence.}) 23... Bc8
>{rest of game removed - TCF} 1/2-1/2
>
>
>Most comments in PGN seem to apply to the move directly before the comment,
>or to be applicable to the position that has been arrived at by the move
>directly before the comment.  Examples of these can be found after moves w4,
>B5, B17, B21 (in the variation) and W25 (in the variation).
>
>My program currently associates comments with the position in the tree where
>the comment occurs, so the above are treated quite well.
>
>The next place for a comment is the initial one ... {Gromit 3.8.2 - ...}.
>This occurs before any moves have been made.
>
>My program copes with this one, as it automatically associates it with the
>root position, which seems to be the correct action in this case.
>
>So, now we get to the comment that is causing me a problem.  It is the one
>at the beginning of the variation of move 23. --> ({Most interesting is} 23.
>Nc6 etc.). My program currently associates the "Most interesting is" with the
>position after 22... b6.  This is almost certainly not the correct thing to
>do.  It definately means that there is a change when I save the game again.
>
>The main problem with this comment is that it is right at the start of a
>variation (before the first move in the variation).  You only really want to
>display it when the user is in the variation, but at the time the comment
>is parsed, there is no variation to hang it on (in my program).  Even worse,
>variations are not explicit in my tree structure.  There are only positions,
>and child positions... there is not explicit storate for edges (moves).  The
>moves are stored in the positions themselves, as are the comments.
>
>
>So, I have a couple of questions which I hope someone may be able to answer :)
>
>1.  In the absence of a standard way of dealing with the comments situation
>    above, what do other people do in their programs?  Maybe I should add a
>    specific Variation class, and if a comment comes before the first move
>    in a variation, I could add it to this.

I would build an explicit tree (not just a list) with positions and moves,
and stick the comments to both, positions and moves.

>2.  Is there a more up-to-date PGN spec than the one I have dated 1994.03.12?
>    If there is, does it say more about comments than the one I have?

That is the one I have and everybody else, so far as I can see.

>Cheers, Tim.

Cheers,
Heiner



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.