]> git.sesse.net Git - stockfish/commit
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)
commit22a5f91aa79e065387e780bbffc1bbadfd84e8d6
treefdaa3584a7d73b57339e3221780ece9c1fe7f622
parent9ce74698463d0b3320892b060f0fbac70415f033
Fix crash under Chess 960

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.
src/movegen.cpp