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

Rename move_is_legal() in move_is_pl()

We disjoint pseudo legal detection from full legal detection.

It will be used by future patches.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2011-05-23 12:04:59 +02:00
parent bc86668ba4
commit 45ce92b89c
5 changed files with 18 additions and 15 deletions

View file

@ -451,7 +451,7 @@ namespace {
// Single and double pawn pushes // Single and double pawn pushes
if (Type != MV_CAPTURE) if (Type != MV_CAPTURE)
{ {
b1 = pawnPushes & emptySquares; b1 = (Type != MV_EVASION ? pawnPushes : pawnPushes & emptySquares);
b2 = move_pawns<TDELTA_N>(pawnPushes & TRank3BB) & emptySquares; b2 = move_pawns<TDELTA_N>(pawnPushes & TRank3BB) & emptySquares;
if (Type == MV_CHECK) if (Type == MV_CHECK)

View file

@ -275,7 +275,8 @@ Move MovePicker::get_next_move() {
case PH_TT_MOVES: case PH_TT_MOVES:
move = (curMove++)->move; move = (curMove++)->move;
if ( move != MOVE_NONE if ( move != MOVE_NONE
&& pos.move_is_legal(move, pinned)) && pos.move_is_pl(move)
&& pos.pl_move_is_legal(move, pinned))
return move; return move;
break; break;
@ -300,7 +301,8 @@ Move MovePicker::get_next_move() {
case PH_KILLERS: case PH_KILLERS:
move = (curMove++)->move; move = (curMove++)->move;
if ( move != MOVE_NONE if ( move != MOVE_NONE
&& pos.move_is_legal(move, pinned) && pos.move_is_pl(move)
&& pos.pl_move_is_legal(move, pinned)
&& move != ttMoves[0].move && move != ttMoves[0].move
&& move != ttMoves[1].move && move != ttMoves[1].move
&& !pos.move_is_capture(move)) && !pos.move_is_capture(move))

View file

@ -628,14 +628,14 @@ bool Position::pl_move_is_legal(Move m, Bitboard pinned) const {
/// move and tests whether the move is legal. This version is not very fast and /// move and tests whether the move is legal. This version is not very fast and
/// should be used only in non time-critical paths. /// should be used only in non time-critical paths.
bool Position::move_is_legal(const Move m) const { bool Position::move_is_pl_full(const Move m) const {
MoveStack mlist[MAX_MOVES]; MoveStack mlist[MAX_MOVES];
MoveStack *cur, *last = generate<MV_PSEUDO_LEGAL>(*this, mlist); MoveStack *cur, *last = generate<MV_PSEUDO_LEGAL>(*this, mlist);
for (cur = mlist; cur != last; cur++) for (cur = mlist; cur != last; cur++)
if (cur->move == m) if (cur->move == m)
return pl_move_is_legal(m, pinned_pieces(sideToMove)); return true;
return false; return false;
} }
@ -644,10 +644,9 @@ bool Position::move_is_legal(const Move m) const {
/// Fast version of Position::move_is_legal() that takes a position a move and /// Fast version of Position::move_is_legal() that takes a position a move and
/// a bitboard of pinned pieces as input, and tests whether the move is legal. /// a bitboard of pinned pieces as input, and tests whether the move is legal.
bool Position::move_is_legal(const Move m, Bitboard pinned) const { bool Position::move_is_pl(const Move m) const {
assert(is_ok()); assert(is_ok());
assert(pinned == pinned_pieces(sideToMove));
Color us = sideToMove; Color us = sideToMove;
Color them = opposite_color(sideToMove); Color them = opposite_color(sideToMove);
@ -657,7 +656,7 @@ bool Position::move_is_legal(const Move m, Bitboard pinned) const {
// Use a slower but simpler function for uncommon cases // Use a slower but simpler function for uncommon cases
if (move_is_special(m)) if (move_is_special(m))
return move_is_legal(m); return move_is_pl_full(m);
// Is not a promotion, so promotion piece must be empty // Is not a promotion, so promotion piece must be empty
if (move_promotion_piece(m) - 2 != PIECE_TYPE_NONE) if (move_promotion_piece(m) - 2 != PIECE_TYPE_NONE)
@ -763,8 +762,7 @@ bool Position::move_is_legal(const Move m, Bitboard pinned) const {
} }
} }
// The move is pseudo-legal, check if it is also legal return true;
return pl_move_is_legal(m, pinned);
} }

View file

@ -186,8 +186,8 @@ public:
// Properties of moves // Properties of moves
bool pl_move_is_legal(Move m, Bitboard pinned) const; bool pl_move_is_legal(Move m, Bitboard pinned) const;
bool move_is_legal(const Move m) const; bool move_is_pl_full(const Move m) const;
bool move_is_legal(const Move m, Bitboard pinned) const; bool move_is_pl(const Move m) const;
bool move_gives_check(Move m) const; bool move_gives_check(Move m) const;
bool move_gives_check(Move m, const CheckInfo& ci) const; bool move_gives_check(Move m, const CheckInfo& ci) const;
bool move_is_capture(Move m) const; bool move_is_capture(Move m) const;

View file

@ -1979,13 +1979,16 @@ split_point_start: // At split points actual search starts from here
TTEntry* tte; TTEntry* tte;
int ply = 1; int ply = 1;
assert(pv[0] != MOVE_NONE && pos.move_is_legal(pv[0])); assert(pv[0] != MOVE_NONE && pos.move_is_pl(pv[0]));
pos.do_move(pv[0], *st++); pos.do_move(pv[0], *st++);
Bitboard pinned = pos.pinned_pieces(pos.side_to_move());
while ( (tte = TT.probe(pos.get_key())) != NULL while ( (tte = TT.probe(pos.get_key())) != NULL
&& tte->move() != MOVE_NONE && tte->move() != MOVE_NONE
&& pos.move_is_legal(tte->move()) && pos.move_is_pl(tte->move())
&& pos.pl_move_is_legal(tte->move(), pinned)
&& ply < PLY_MAX && ply < PLY_MAX
&& (!pos.is_draw() || ply < 2)) && (!pos.is_draw() || ply < 2))
{ {
@ -2009,7 +2012,7 @@ split_point_start: // At split points actual search starts from here
Value v, m = VALUE_NONE; Value v, m = VALUE_NONE;
int ply = 0; int ply = 0;
assert(pv[0] != MOVE_NONE && pos.move_is_legal(pv[0])); assert(pv[0] != MOVE_NONE && pos.move_is_pl(pv[0]));
do { do {
k = pos.get_key(); k = pos.get_key();