1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 08:43:09 +00:00

Do not pass pinned argument in Position::pl_move_is_legal()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2009-02-19 16:48:57 +01:00
parent 0a0ea36e25
commit 734941672e
4 changed files with 12 additions and 23 deletions

View file

@ -360,7 +360,7 @@ int generate_legal_moves(const Position& pos, MoveStack* mlist) {
// Remove illegal moves from the list // Remove illegal moves from the list
for (int i = 0; i < n; i++) for (int i = 0; i < n; i++)
if (!pos.pl_move_is_legal(mlist[i].move, pinned)) if (!pos.pl_move_is_legal(mlist[i].move))
mlist[i--].move = mlist[--n].move; mlist[i--].move = mlist[--n].move;
return n; return n;
@ -405,7 +405,7 @@ bool move_is_legal(const Position& pos, const Move m) {
assert(pos.piece_on(to - pawn_push(us)) == piece_of_color_and_type(them, PAWN)); assert(pos.piece_on(to - pawn_push(us)) == piece_of_color_and_type(them, PAWN));
// The move is pseudo-legal, check if it is also legal // The move is pseudo-legal, check if it is also legal
return pos.pl_move_is_legal(m, pinned); return pos.pl_move_is_legal(m);
} }
// Castling moves // Castling moves
@ -537,12 +537,12 @@ bool move_is_legal(const Position& pos, const Move m) {
return false; return false;
} }
// The move is pseudo-legal, check if it is also legal // The move is pseudo-legal, check if it is also legal
return pos.pl_move_is_legal(m, pinned); return pos.pl_move_is_legal(m);
} }
// Luckly we can handle all the other pieces in one go // Luckly we can handle all the other pieces in one go
return ( pos.piece_attacks_square(pos.piece_on(from), from, to) return ( pos.piece_attacks_square(pos.piece_on(from), from, to)
&& pos.pl_move_is_legal(m, pinned) && pos.pl_move_is_legal(m)
&& !move_promotion(m)); && !move_promotion(m));
} }

View file

@ -394,7 +394,7 @@ Move MovePicker::pick_move_from_list() {
moves[bestIndex] = moves[movesPicked++]; moves[bestIndex] = moves[movesPicked++];
if ( move != ttMove if ( move != ttMove
&& move != mateKiller && move != mateKiller
&& pos.pl_move_is_legal(move, pinned)) && pos.pl_move_is_legal(move))
return move; return move;
} }
break; break;
@ -414,7 +414,7 @@ Move MovePicker::pick_move_from_list() {
moves[bestIndex] = moves[movesPicked++]; moves[bestIndex] = moves[movesPicked++];
if ( move != ttMove if ( move != ttMove
&& move != mateKiller && move != mateKiller
&& pos.pl_move_is_legal(move, pinned)) && pos.pl_move_is_legal(move))
return move; return move;
} }
break; break;
@ -442,7 +442,7 @@ Move MovePicker::pick_move_from_list() {
move = badCaptures[movesPicked++].move; move = badCaptures[movesPicked++].move;
if ( move != ttMove if ( move != ttMove
&& move != mateKiller && move != mateKiller
&& pos.pl_move_is_legal(move, pinned)) && pos.pl_move_is_legal(move))
return move; return move;
} }
break; break;
@ -457,7 +457,7 @@ Move MovePicker::pick_move_from_list() {
moves[bestIndex] = moves[movesPicked++]; moves[bestIndex] = moves[movesPicked++];
// Remember to change the line below if we decide to hash the qsearch! // Remember to change the line below if we decide to hash the qsearch!
// Maybe also postpone the legality check until after futility pruning? // Maybe also postpone the legality check until after futility pruning?
if (/* move != ttMove && */ pos.pl_move_is_legal(move, pinned)) if (/* move != ttMove && */ pos.pl_move_is_legal(move))
return move; return move;
} }
break; break;
@ -471,7 +471,7 @@ Move MovePicker::pick_move_from_list() {
{ {
move = moves[movesPicked++].move; move = moves[movesPicked++].move;
// Remember to change the line below if we decide to hash the qsearch! // Remember to change the line below if we decide to hash the qsearch!
if (/* move != ttMove && */ pos.pl_move_is_legal(move, pinned)) if (/* move != ttMove && */ pos.pl_move_is_legal(move))
return move; return move;
} }
break; break;

View file

@ -478,22 +478,12 @@ void Position::find_checkers() {
} }
/// Position::pl_move_is_legal() tests whether a pseudo-legal move is legal. /// Position::pl_move_is_legal() tests whether a pseudo-legal move is legal
/// There are two versions of this function: One which takes only a
/// move as input, and one which takes a move and a bitboard of pinned
/// pieces. The latter function is faster, and should always be preferred
/// when a pinned piece bitboard has already been computed.
bool Position::pl_move_is_legal(Move m) const { bool Position::pl_move_is_legal(Move m) const {
return pl_move_is_legal(m, pinned_pieces(side_to_move()));
}
bool Position::pl_move_is_legal(Move m, Bitboard pinned) const {
assert(is_ok()); assert(is_ok());
assert(move_is_ok(m)); assert(move_is_ok(m));
assert(pinned == pinned_pieces(side_to_move()));
// If we're in check, all pseudo-legal moves are legal, because our // If we're in check, all pseudo-legal moves are legal, because our
// check evasion generator only generates true legal moves. // check evasion generator only generates true legal moves.
@ -541,7 +531,7 @@ bool Position::pl_move_is_legal(Move m, Bitboard pinned) const {
// A non-king move is legal if and only if it is not pinned or it // A non-king move is legal if and only if it is not pinned or it
// is moving along the ray towards or away from the king. // is moving along the ray towards or away from the king.
return ( !bit_is_set(pinned, from) return ( !bit_is_set(pinned_pieces(us), from)
|| (direction_between_squares(from, ksq) == direction_between_squares(move_to(m), ksq))); || (direction_between_squares(from, ksq) == direction_between_squares(move_to(m), ksq)));
} }

View file

@ -220,7 +220,6 @@ public:
// Properties of moves // Properties of moves
bool pl_move_is_legal(Move m) const; bool pl_move_is_legal(Move m) const;
bool pl_move_is_legal(Move m, Bitboard pinned) const;
bool move_is_check(Move m) const; bool move_is_check(Move m) const;
bool move_is_check(Move m, Bitboard dcCandidates) const; bool move_is_check(Move m, Bitboard dcCandidates) const;
bool move_is_capture(Move m) const; bool move_is_capture(Move m) const;