23 September 2017

Start by Placing the Bishops!

Looking for code to generate a chess960 start position randomly? Don't overlook Generate Chess960 Starting Position (rosettacode.org): 'You are encouraged to solve this task according to the task description, using any language you may know.'

The page currently offers 35 solutions in programming languages from A to Z (literally, AutoHotkey to zkl), but I have no idea how many different algorithms are used. Some algorithms appear to be suspect, especially those that start by placing the RKR, then fill in the other pieces.

The reason is that although there are 56 different RKR patterns, some of them have 18 associated start positions, others have only 12. The difference occurs when the RKR all start on the same square color. For more about this, see Castling Patterns Visualized (September 2010).

***

Later: After I wrote this post, I noticed that the 'Task' on the Rosetta Code page is wrong. Instead of

The purpose of this task is to write a program that can randomly generate any one of the 960 Chess960 initial positions.

it should say something like 'randomly generate with equal probability'. Specification errors are worse than coding errors!

No comments: