[Retros] Castling and repetition

Francois Labelle flab at EECS.Berkeley.EDU
Fri Oct 26 01:51:21 EDT 2007


If Mathematics doesn't give an answer, then maybe Computer Science does!

My chess engine defines castling rights like this:

The starting position has K = Q = k = q = true;
After each move do the following:
- if (the square h1 does not contain a white rook) K = false;
- if (the square a1 does not contain a white rook) Q = false;
- if (the square h8 does not contain a black rook) k = false;
- if (the square a8 does not contain a black rook) q = false;
- if (the white king moved) K = Q = false;
- if (the black king moved) k = q = false;

And the reason is that this is the simplest definition that gets the job
done (i.e. these four bits + the diagram + the en passant square allow the
move generator to generate exactly the set of legal moves).

Francois



More information about the Retros mailing list