mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 01:03: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:
|
case DELTA_SE:
|
||||||
// Capture. The destination square must be occupied by an enemy
|
// Capture. The destination square must be occupied by an enemy
|
||||||
// piece (en passant captures was handled earlier).
|
// piece (en passant captures was handled earlier).
|
||||||
if (color_of_piece_on(to) != them)
|
if (color_of_piece_on(to) != them)
|
||||||
return false;
|
return false;
|
||||||
break;
|
|
||||||
|
// 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_N:
|
||||||
case DELTA_S:
|
case DELTA_S:
|
||||||
// Pawn push. The destination square must be empty.
|
// Pawn push. The destination square must be empty.
|
||||||
if (!square_is_empty(to))
|
if (!square_is_empty(to))
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DELTA_NN:
|
case DELTA_NN:
|
||||||
// Double white pawn push. The destination square must be on the fourth
|
// 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(to)
|
||||||
|| !square_is_empty(from + DELTA_N))
|
|| !square_is_empty(from + DELTA_N))
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DELTA_SS:
|
case DELTA_SS:
|
||||||
// Double black pawn push. The destination square must be on the fifth
|
// Double black pawn push. The destination square must be on the fifth
|
||||||
// rank, and both the destination square and the square between the
|
// rank, and both the destination square and the square between the
|
||||||
// source and destination squares must be empty.
|
// source and destination squares must be empty.
|
||||||
if ( square_rank(to) != RANK_5
|
if ( square_rank(to) != RANK_5
|
||||||
|| !square_is_empty(to)
|
|| !square_is_empty(to)
|
||||||
|| !square_is_empty(from + DELTA_S))
|
|| !square_is_empty(from + DELTA_S))
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue