]> git.sesse.net Git - stockfish/commitdiff
Fix crash under Chess 960
authorMarco Costalba <mcostalba@gmail.com>
Sun, 16 Sep 2012 12:06:13 +0000 (14:06 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 16 Sep 2012 12:14:55 +0000 (14:14 +0200)
We have a crash with this position:

rkqbnnbr/pppppppp/8/8/8/8/PPPPPPPP/RKQBNNBR w HAha -

What happens is that even if we are castling QUEEN_SIDE,
in this case we have kfrom (B8) < kto (C8) so the loop
that checks for attackers runs forever leading to a crash.

The fix is to check for (kto > kfrom) instead of
Side == KING_SIDE, but this is slower in the normal case of
ortodhox chess, so rewrite generate_castle() to handle the
chess960 case as a template parameter and allow the compiler
to optimize out the comparison in case of normal chess.

Reported by Ray Banks.


No differences found