by H.G.Muller » 04 Nov 2009, 08:32
This would require a major redesign. Currently, the heart of XBoard is a single stack of boards, which cntains the game history, through which you can step with the arrow keys. I guess what is needed is another stack of boards, where you can shelve the top of the game-history stack when you start playing out a variation. (Currently this just discards the top of the game-history stack.) Pressing "revert" could then restore the game history and erase the variation you have just been building.
A similar issue is variations in a PGN. Currently they are treated as comments, saved as text with every move. There could be a menu item for shelving the rest of the main line, parse the variation, and substitute that for the remainder of the game. This would then contain sub-variations as comments, so that you could repeat the process. XBoard would have to keep track of how many levels deep you are in the sub-variation tree, and "revert" should then restore one level. So the shelving memory should be organized as a stack. Each variation would have to remember the original first and last plyNumber of the game history, and from where to where they are stored in the shelving stack. Of course the shelving stack could be simply the high end of the normal game-history array, growing down.
Hmm, this sounds not so difficult as I first thought. In fact it could be almost trivial...
Before it can be implemented, a known bug in the storing of comments should be fixed, though. Currently everything between {}, () or [] is considered comment, and the delimeters are stripped off before concatenating those that belong to the same move. On saving the PGN the whole thinng is then put between {}. This loses the sub-variation parentheses. It also produces invalid PGN, with nested {{}}, if there originlly was a variation that contained a comment: ({}). So the system must be changed first to save comments including their original delimiters.
Of course after playing out a variation, there must be a revert option that appends this variation as a comment to the move to which you revert.
This sounds like a great idea. I will think some more about it, in particular how it could be combined with my idea to play "tree matches" between therr engines, for comparing closely related engines (i.e. play A and A' against B.) This would naturally produce a tree of variations, as A and A' would now and then choose different moves, which would then be played out by both A and A'. The sequel of the move from A could then be designated "main line", the sequel of the move by A' the "variation". I guess the XBoard PGN parser would have to be improved to handle sufficiently deep nesting of sub-variations in this case.