mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 08:43:09 +00:00
Fix a bug in Position::is_ok()
If we cannot castle castleRightsMask[] could be not valid, for instance when king initial file is FILE_A as queen rook. In this case castleRightsMask[] at initialQRFile is different from the expected (ALL_CASTLES ^ WHITE_OOO). No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
ae2f5f25cd
commit
9305983018
1 changed files with 13 additions and 8 deletions
|
@ -2039,6 +2039,10 @@ bool Position::is_ok(int* failedStep) const {
|
|||
if (can_castle_queenside(c) && piece_on(initial_qr_square(c)) != make_piece(c, ROOK))
|
||||
return false;
|
||||
}
|
||||
// If we cannot castle castleRightsMask[] could be not valid, for instance when
|
||||
// king initial file is FILE_A as queen rook.
|
||||
if (can_castle(WHITE) || can_castle(BLACK))
|
||||
{
|
||||
if (castleRightsMask[initial_kr_square(WHITE)] != (ALL_CASTLES ^ WHITE_OO))
|
||||
return false;
|
||||
if (castleRightsMask[initial_qr_square(WHITE)] != (ALL_CASTLES ^ WHITE_OOO))
|
||||
|
@ -2048,6 +2052,7 @@ bool Position::is_ok(int* failedStep) const {
|
|||
if (castleRightsMask[initial_qr_square(BLACK)] != (ALL_CASTLES ^ BLACK_OOO))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (failedStep) *failedStep = 0;
|
||||
return true;
|
||||
|
|
Loading…
Add table
Reference in a new issue