From 45ce92b89c9191f1606d82611620587157956e1b Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Mon, 23 May 2011 12:04:59 +0200 Subject: [PATCH] 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 --- src/movegen.cpp | 2 +- src/movepick.cpp | 6 ++++-- src/position.cpp | 12 +++++------- src/position.h | 4 ++-- src/search.cpp | 9 ++++++--- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/movegen.cpp b/src/movegen.cpp index f38d4226..297b51ff 100644 --- a/src/movegen.cpp +++ b/src/movegen.cpp @@ -451,7 +451,7 @@ namespace { // Single and double pawn pushes if (Type != MV_CAPTURE) { - b1 = pawnPushes & emptySquares; + b1 = (Type != MV_EVASION ? pawnPushes : pawnPushes & emptySquares); b2 = move_pawns(pawnPushes & TRank3BB) & emptySquares; if (Type == MV_CHECK) diff --git a/src/movepick.cpp b/src/movepick.cpp index 69d60bad..6a4b26ee 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -275,7 +275,8 @@ Move MovePicker::get_next_move() { case PH_TT_MOVES: move = (curMove++)->move; if ( move != MOVE_NONE - && pos.move_is_legal(move, pinned)) + && pos.move_is_pl(move) + && pos.pl_move_is_legal(move, pinned)) return move; break; @@ -300,7 +301,8 @@ Move MovePicker::get_next_move() { case PH_KILLERS: move = (curMove++)->move; 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[1].move && !pos.move_is_capture(move)) diff --git a/src/position.cpp b/src/position.cpp index 3cc3bfeb..4c925f5b 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -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 /// 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 *cur, *last = generate(*this, mlist); for (cur = mlist; cur != last; cur++) if (cur->move == m) - return pl_move_is_legal(m, pinned_pieces(sideToMove)); + return true; 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 /// 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(pinned == pinned_pieces(sideToMove)); Color us = 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 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 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 pl_move_is_legal(m, pinned); + return true; } diff --git a/src/position.h b/src/position.h index e560a097..496b7b9d 100644 --- a/src/position.h +++ b/src/position.h @@ -186,8 +186,8 @@ public: // Properties of moves bool pl_move_is_legal(Move m, Bitboard pinned) const; - bool move_is_legal(const Move m) const; - bool move_is_legal(const Move m, Bitboard pinned) const; + bool move_is_pl_full(const Move m) const; + bool move_is_pl(const Move m) const; bool move_gives_check(Move m) const; bool move_gives_check(Move m, const CheckInfo& ci) const; bool move_is_capture(Move m) const; diff --git a/src/search.cpp b/src/search.cpp index 2fdd2840..516ff100 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -1979,13 +1979,16 @@ split_point_start: // At split points actual search starts from here TTEntry* tte; 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++); + Bitboard pinned = pos.pinned_pieces(pos.side_to_move()); + while ( (tte = TT.probe(pos.get_key())) != NULL && 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 && (!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; 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 { k = pos.get_key(); -- 2.39.2