mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 16:53:09 +00:00
Add file distance condition in move_is_legal()
Found another missed control in move_is_legal() thanks to brute force testing. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
ff9e49bac9
commit
21fc66c246
1 changed files with 16 additions and 12 deletions
|
@ -712,16 +712,20 @@ bool Position::move_is_legal(const Move m, Bitboard pinned) const {
|
|||
case DELTA_SE:
|
||||
// Capture. The destination square must be occupied by an enemy
|
||||
// piece (en passant captures was handled earlier).
|
||||
if (color_of_piece_on(to) != them)
|
||||
return false;
|
||||
break;
|
||||
if (color_of_piece_on(to) != them)
|
||||
return false;
|
||||
|
||||
// From and to files must be one file apart, avoids a7h5
|
||||
if (abs(square_file(from) - square_file(to)) != 1)
|
||||
return false;
|
||||
break;
|
||||
|
||||
case DELTA_N:
|
||||
case DELTA_S:
|
||||
// Pawn push. The destination square must be empty.
|
||||
if (!square_is_empty(to))
|
||||
return false;
|
||||
break;
|
||||
if (!square_is_empty(to))
|
||||
return false;
|
||||
break;
|
||||
|
||||
case DELTA_NN:
|
||||
// Double white pawn push. The destination square must be on the fourth
|
||||
|
@ -731,17 +735,17 @@ bool Position::move_is_legal(const Move m, Bitboard pinned) const {
|
|||
|| !square_is_empty(to)
|
||||
|| !square_is_empty(from + DELTA_N))
|
||||
return false;
|
||||
break;
|
||||
break;
|
||||
|
||||
case DELTA_SS:
|
||||
// Double black pawn push. The destination square must be on the fifth
|
||||
// rank, and both the destination square and the square between the
|
||||
// source and destination squares must be empty.
|
||||
if ( square_rank(to) != RANK_5
|
||||
|| !square_is_empty(to)
|
||||
|| !square_is_empty(from + DELTA_S))
|
||||
return false;
|
||||
break;
|
||||
if ( square_rank(to) != RANK_5
|
||||
|| !square_is_empty(to)
|
||||
|| !square_is_empty(from + DELTA_S))
|
||||
return false;
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
|
|
Loading…
Add table
Reference in a new issue