Skip to content

Journal Entry #12

November 22, 2010

I’ve been working on the program, but not documenting progress here, for more than a week now. Sorry about that. As I’ve mentioned before, it’s hard to make a worthwhile post if you have nothing tangible to report. For a while now I’ve had the additional problem that it’s rather difficult to even describe what I’ve been working on. Basically I hit a speed bump, now that I’m (more or less) through it, I feel capable of describing it.

Basically I’ve been working on the game management features. The most important features of Tarrasch are concerned with creating and editing individual games, which means working with moves, variations and comments. But Tarrasch V2 must allow effective manipulation of whole .pgn files as well. That means a mode in which the smallest unit of information is a whole game. This is not rocket science. I offer the user a scrollable list that shows all the games in a .pgn file. The user can select a game to work with, which effectively exits the game manipulation phase and returns to the mainstream activity of working with an individual game. But of course I must provide other game manipulation features. The user can sort the games by clicking column headings. Or edit  game details (players, site, tournament, date etc.) I’ve blogged about those features before.

Of course the user can select one or many games and delete, cut, copy and paste. Copy works in the conventional way, that is the clipboard is emptied immediately before the start of each copy. That can be annoying so I offer an “Add to clipboard” feature as well as copy. The other features I offer are “Save file”, “Paste current game” and “Renumber”. Obviously save file lets the user save the modified .pgn file after deleting or pasting games. Paste current game allows the user an alternative way to save a game. Normally they would use “Save” or “Save as” from the file menu. The alternative way is to open a file after creating a game from scratch and then “Past current game” into the list of games. “Renumber” allows the user to save the games in the order they appear on screen (typically after a sort) rather than in their original order. This is a feature I think is missing in ChessBase (maybe it’s present but too deeply buried or obscure for me to find).

That is rather a lot of detail. As I worked on this stuff I realised there is a simple way to think about all of this work. Basically I’ve been doing CRUD programming. This is a disdainful term programmers use to describe standard business programming which so often comes down to Creating, Reading, Updating and Deleting records within databases. I knew CRUD programming was typically more time consuming and annoying than you might expect it to be, but didn’t recognise that I faced a CRUD task until I was half way through it !

Let me give you a tangible example of some of the difficulties I have been wrestling with. I have mentioned in a previous post that at any time the user can summon the game list for the current file (i.e. you can look at the list of games at any time, not just when you first open the file). I also allow the user to look at a couple of other game lists as well. The other lists are the “session” and the “clipboard”.  The “session” is just a list of the games you’ve been working with since you started the program. The “clipboard” is, well it’s the clipboard. I think it is cool to let the user look at the clipboard.

Consider the following scenario. The user opens a big .pgn file, cuts most of the games to the clipboard, saves the (now much smaller) file. The user opens a second big .pgn file, selects most of the games, adds them to the clipboard, deletes them, saves the (now much smaller) file. Now the user looks at the list of games in the clipboard. The clipboard shows a huge list of games, nearly all the games from both the big .pgn files, and in fact those big .pgn files are now both small .pgn files. If the user picks one of the games from the clipboard to load and work with, where does it come from ? I really don’t want to keep all the games in memory, that’s not very scalable. On the other hand the file the game is coming from has been modified, and in particular the game has been deleted from that file.

This gave me quite a headache. I will outline in broad terms how my solution works. The conventional approach to saving a modified .pgn file would be to open the original .pgn file for reading, and then create a temporary working file to write to. Then everything we are keeping is written to the temporary file, and if and only if all goes well, we delete the original and rename the temporary to the original’s name. I modify this approach. Instead of deleting the original I rename it to (another) temporary file name. I keep this temporary file for the whole session. The clipboard games in our troubling scenario can be readily located in one of these temporary files. Simple and effective but it didn’t occur to me until all alternatives had been considered and rejected as too complicated and impractical. As Homer Simpson might say Doh!

Well I could write more about some of the other minutiae I’ve been looking at, but I’ll save us the bother by calling time on this for now. Talk again soon!

2 Comments leave one →
  1. zass permalink
    December 2, 2010 10:16 pm

    I just wanted to say thanks for working on this, and give feedback on an annoying feature of the current program.

    If I start a new position (either new game or a new FEN), and then make a couple of moves, I can only “undo” up to the second move. I can’t undo the first move. This is annoying in positional analysis where I will want to consider several starting moves, but I have to go back to position setup each time, since I can’t rewind that first move.

    • December 2, 2010 10:58 pm

      That’s a very good point. I have previously received a complaint that it was impossible to undo back to the opening position. I accepted that that was a flaw, but I decided it was not too serious. I didn’t have this problem in Reptor, my previous program, but then I had an ugly kind of dummy empty move representing “move 0”. I decided getting rid of that pseudo move was worth the annoyance of not being able to undo the very first move. You make the same point, but I see now that the problem is more serious in the scenario you talk about, where instead of the standard start position, the user has entered a custom start position.

      The good news is that this is absolutely not a problem in Tarrasch V2. I think I have solved this problematic little issue very intuitively and elegantly. The game moves are now shown across the page (as in most serious chess programs) rather than in a vertical list. I use a conventional cursor and you can position it anywhere in the page. If the cursor sits anywhere in the first move, then the board will show the position after the first move. If the cursor sits directly before the first move then the board will show the position before the first move.

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s

%d bloggers like this: