05 December 2010

Chess960 Position Generator Revisited

After posting about Another Chess960 Position Generator, it occurred to me that the source I had corrected as the base for my own position generator contained a logical error. It was a small error, reducing the number of times that the first position (SP000 BBQNNRKR) would be randomly generated, but that was enough to render it unusable.

To test my concern, I wrote a driver to call the generator thousands of times and to count the number of times each position was generated. Sure enough, the count for SP000 was approximately half of the count for the other SPs (Start Positions). After fixing the logical error, and feeling more confident about my Javascript skills, I decided to take a closer look at another generator I identified for my post on Chess960 Position Generators on the Web, i.e. the generator at very.co.il/services from a company called Very Ltd.

This second generator, based on the same die-rolling technique used by people to generate a chess960 position, was more sophisticated than the generator I had studied for the first cut. I adapted it to my needs, used my driver to verify its accuracy, and updated my page of Chess960 [Fischer Random Chess] Start Positions to use the adaptation. At the same time I incorporated a comment made to Another Generator to improve the presentation of my generator.

While doing the above, I realized that the IF/THEN table technique used to convert between SPs and their corresponding numbers ('If ID=SP000 then SP=BBQNNRKR' or vice versa) could be replaced by the method described in Calculate SP Numbers in Your Head. I'll do that in another programming project.

No comments: