28 November 2010

Another Chess960 Position Generator

Continuing with Chess960 Position Generators on the Web, I decided to adapt one of the existing chess960 position generators to do the job I had in mind. The only real candidate was the tool at Chess-960.org, because it incorporated the notion of a standard numbering system. Fortunately, it used Javascript, making it easy to adapt. On opening the Javascript file, I discovered that it was relatively straightforward, as the chess960 intelligence was coded in the form of IF/THEN tables: 'If position = BQNBNRKR, then ID = 001', or 'If ID = 959, then position = RKRNNQBB'. I could definitely work with that, even with my rusty programming skills.

The main task was to investigate the source of the problem mentioned in Impediments to Chess960 Acceptance. Did I just happen to stumble on the only error in the original code or were there more? I extracted the ID/position equivalences, compared them to my database of SPs, and found a dozen discrepancies. The most obvious error was the assignment of SP000 (BBQNNRKR) to no.960, because the standard numbering scheme starts at 000 and ends at 959. As for the other errors, they were all incorrect ID/position equivalences scattered at random in the IF/THEN tables.

I replaced all the original equivalences with my own, made a few other changes, and added the position generator to my page of Chess960 Start Positions. On top of a working chess960 generator, I have a foundation for any related ideas that might come along.

1 comment:

HarryO said...

Thanks very much for going to the effort to do this. You could promote your work to put the generator at the top of the form rather than at the bottom. A possible improvement would be to have only one text box and one random generator button. If you press the button you get a random SP. If you type the position number into the text box you are presented with SP piece setup for that number. If you type in the piece setup you are presented with the number. For each presentation you are also informed of the equivalent twin both in number and piece notation as well as the PGN notation. For extra information, the form could also list all positions that have a pre-designated characteristic in common with the selected SP. For example here are some common characteristics that could be useful:
1) All positions with the knights in the same spot
and/or:
2) All positions that have the king and rooks in the same spot

The rationale is that the knights are the absolute critical pieces for us humans to understand the character of an SP and the rooks and king form the fundamental framework of the SP.

Thanks again, best wishes, cheers and thanks
Harry

PS) I also think the mental arithmetic way for calculating the SP number is marvelous and I will use it to practice not to get my head rusty for mental arithmetic (but it is anyway).