Skip to content

Journal Entry #11

November 8, 2010

I caught up with something that’s been worrying me a long time today. I added support for the “result” of the game both onscreen and in .pgn files generated by Tarrasch. This is a small but essential detail. Until today loading a game would show all the moves, annotations and comments … except for one essential piece of information, the result of the game. In this context the result can have four values only; “1-0”, “0-1”, “1/2-1/2” or “*”. This last value is used for “lines” rather than “games”, it’s important as the last token of text in a .pgn file, but I don’t bother displaying the asterisk on screen.

You might wonder why such an apparently trivial thing would “worry” me. Well the trouble is, that the result appears in .pgn files as a kind of special move, and I was worried that I would have to make a fundamental change to my move trees to support this special, odd kind of move. I started out on that track this morning, but not for long, it was just going to cause too many changes. With a sigh of relief I identified and implemented a simpler solution, basically making the result an (optional) attribute of a move within a tree. Moves already have other optional attributes (like whether the move is followed by a comment), and this approach was very simple by comparison. The downside is that the size of my move trees has increased, since every single node within the tree needs this new optional attribute. But as I mentioned a few posts ago, it is not a good idea to over optimise for performance at this stage of the development. Better to take the simplest route and optimise later if it’s really needed.

 

One Comment leave one →
  1. December 7, 2010 4:28 am

    It is a little weird to comment on my own post, but I thought it was worthwhile to document that I have just reworked this area. A careful reading of the .pgn specification reveals that the result cannot really be treated like a special move at all. It is only allowed as the last token in the move section of a game within a .pgn file. As such it is absolutely an attribute of a game, rather than of a move (even with a restriction that the move must be at the end of a variation). For example if the last move of the main variation has a subvariation, then the result must appear after the subvariation, not something that you’d normally do if the result was attached to the move.

    This is actually a simpler situation to the one I envisaged. For example I imagined that when demoting a main variation, with a result (for example 1-0), then that result would still be attached to the end of the demoted variation. Not possible in a straightforward way with .pgn, the token 1-0 cannot simply appear at the end of a variation, it would need to be put in a comment. I’ve decided that would be confusing all around and more trouble than it’s worth.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: