From 94dcac1feeb142a56ed2ebddb96ef672460f1d49 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Wed, 4 Nov 2009 14:46:16 +0100 Subject: [PATCH] Retire MovePicker::discovered_check_candidates() It is now no more needed to know dc candidates inside MovePicker, so avoid calculating there. No functional change. Signed-off-by: Marco Costalba --- src/movegen.cpp | 3 ++- src/movegen.h | 2 +- src/movepick.cpp | 7 ++----- src/movepick.h | 11 +---------- src/position.cpp | 3 +-- src/search.cpp | 9 +++++---- 6 files changed, 12 insertions(+), 23 deletions(-) diff --git a/src/movegen.cpp b/src/movegen.cpp index 18fb0943..4784e95d 100644 --- a/src/movegen.cpp +++ b/src/movegen.cpp @@ -143,13 +143,14 @@ MoveStack* generate_noncaptures(const Position& pos, MoveStack* mlist) { /// generate_non_capture_checks() generates all pseudo-legal non-captures and knight /// underpromotions that give check. Returns a pointer to the end of the move list. -MoveStack* generate_non_capture_checks(const Position& pos, MoveStack* mlist, Bitboard dc) { +MoveStack* generate_non_capture_checks(const Position& pos, MoveStack* mlist) { assert(pos.is_ok()); assert(!pos.is_check()); Color us = pos.side_to_move(); Square ksq = pos.king_square(opposite_color(us)); + Bitboard dc = pos.discovered_check_candidates(us); assert(pos.piece_on(ksq) == piece_of_color_and_type(opposite_color(us), KING)); diff --git a/src/movegen.h b/src/movegen.h index 7d2efec3..88d64053 100644 --- a/src/movegen.h +++ b/src/movegen.h @@ -34,7 +34,7 @@ extern MoveStack* generate_captures(const Position& pos, MoveStack* mlist); extern MoveStack* generate_noncaptures(const Position& pos, MoveStack* mlist); -extern MoveStack* generate_non_capture_checks(const Position& pos, MoveStack* mlist, Bitboard dc); +extern MoveStack* generate_non_capture_checks(const Position& pos, MoveStack* mlist); extern MoveStack* generate_evasions(const Position& pos, MoveStack* mlist); extern MoveStack* generate_moves(const Position& pos, MoveStack* mlist, bool pseudoLegal = false); extern bool move_is_legal(const Position& pos, const Move m, Bitboard pinned); diff --git a/src/movepick.cpp b/src/movepick.cpp index a562662e..26627474 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -86,10 +86,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, } else ttMoves[1].move = killers[0].move = killers[1].move = MOVE_NONE; - Color us = pos.side_to_move(); - - dc = p.discovered_check_candidates(us); - pinned = p.pinned_pieces(us); + pinned = p.pinned_pieces(pos.side_to_move()); if (p.is_check()) phasePtr = EvasionsPhaseTable; @@ -155,7 +152,7 @@ void MovePicker::go_next_phase() { case PH_QCHECKS: // Perhaps we should order moves move here? FIXME - lastMove = generate_non_capture_checks(pos, moves, dc); + lastMove = generate_non_capture_checks(pos, moves); return; case PH_STOP: diff --git a/src/movepick.h b/src/movepick.h index 6c736299..09ad1c39 100644 --- a/src/movepick.h +++ b/src/movepick.h @@ -54,7 +54,6 @@ public: Move get_next_move(); Move get_next_move(Lock& lock); int number_of_evasions() const; - Bitboard discovered_check_candidates() const; private: void score_captures(); @@ -69,7 +68,7 @@ private: int phase; const uint8_t* phasePtr; MoveStack *curMove, *lastMove, *lastBadCapture; - Bitboard dc, pinned; + Bitboard pinned; MoveStack moves[256], badCaptures[64]; }; @@ -88,12 +87,4 @@ inline int MovePicker::number_of_evasions() const { return int(lastMove - moves); } -/// MovePicker::discovered_check_candidates() returns a bitboard containing -/// all pieces which can possibly give discovered check. This bitboard is -/// computed by the constructor function. - -inline Bitboard MovePicker::discovered_check_candidates() const { - return dc; -} - #endif // !defined(MOVEPICK_H_INCLUDED) diff --git a/src/position.cpp b/src/position.cpp index 306cebfc..c6c20dbc 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -1718,11 +1718,10 @@ bool Position::has_mate_threat(Color c) { MoveStack mlist[120]; bool result = false; - Bitboard dc = discovered_check_candidates(sideToMove); Bitboard pinned = pinned_pieces(sideToMove); // Generate pseudo-legal non-capture and capture check moves - MoveStack* last = generate_non_capture_checks(*this, mlist, dc); + MoveStack* last = generate_non_capture_checks(*this, mlist); last = generate_captures(*this, last); // Loop through the moves, and see if one of them is mate diff --git a/src/search.cpp b/src/search.cpp index c323de5d..978041e8 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -334,7 +334,7 @@ int perft(Position& pos, Depth depth) { Move move; MovePicker mp = MovePicker(pos, MOVE_NONE, depth, H); - Bitboard dcCandidates = mp.discovered_check_candidates(); + Bitboard dcCandidates = pos.discovered_check_candidates(pos.side_to_move()); int sum = 0; // If we are at the last ply we don't need to do and undo @@ -1110,7 +1110,7 @@ namespace { bool mateThreat = pos.has_mate_threat(opposite_color(us)); MovePicker mp = MovePicker(pos, ttMove, depth, H, &ss[ply]); - Bitboard dcCandidates = mp.discovered_check_candidates(); + Bitboard dcCandidates = pos.discovered_check_candidates(us); // Loop through all legal moves until no moves remain or a beta cutoff // occurs. @@ -1363,7 +1363,8 @@ namespace { Move move, movesSearched[256]; int moveCount = 0; Value value, bestValue = -VALUE_INFINITE; - Bitboard dcCandidates = mp.discovered_check_candidates(); + Color us = pos.side_to_move(); + Bitboard dcCandidates = pos.discovered_check_candidates(us); Value futilityValue = VALUE_NONE; bool useFutilityPruning = depth < SelectiveDepth && !isCheck; @@ -1583,8 +1584,8 @@ namespace { MovePicker mp = MovePicker(pos, ttMove, depth, H); Move move; int moveCount = 0; - Bitboard dcCandidates = mp.discovered_check_candidates(); Color us = pos.side_to_move(); + Bitboard dcCandidates = pos.discovered_check_candidates(us); bool enoughMaterial = pos.non_pawn_material(us) > RookValueMidgame; // Loop through the moves until no moves remain or a beta cutoff -- 2.39.2