X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fmovepick.cpp;h=4eb842a0e3e7d9eda96a7bf1e7a1ff1c599bb013;hp=4c75b0fe2c00dfb0e464f113e9ad911cb53b57a6;hb=8da2153ee89dd6874cdf35bacedcc73ea8d13d2c;hpb=734941672ee239636d4327525243c39261a9b171 diff --git a/src/movepick.cpp b/src/movepick.cpp index 4c75b0fe..4eb842a0 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -45,9 +45,7 @@ namespace { int MainSearchPhaseIndex; int EvasionsPhaseIndex; int QsearchWithChecksPhaseIndex; - int QsearchNoCapturesPhaseIndex; int QsearchWithoutChecksPhaseIndex; - int NoMovesPhaseIndex; } @@ -66,7 +64,7 @@ namespace { /// move ordering is at the current node. MovePicker::MovePicker(const Position& p, bool pv, Move ttm, - const SearchStack& ss, Depth d, EvalInfo* ei) : pos(p) { + const SearchStack& ss, Depth d) : pos(p) { pvNode = pv; ttMove = ttm; mateKiller = (ss.mateKiller == ttm)? MOVE_NONE : ss.mateKiller; @@ -77,27 +75,19 @@ MovePicker::MovePicker(const Position& p, bool pv, Move ttm, numOfMoves = 0; numOfBadCaptures = 0; - // With EvalInfo we are able to know how many captures are possible before - // generating them. So avoid generating in case we know are zero. - Color us = pos.side_to_move(); - Color them = opposite_color(us); - bool noCaptures = ei - && (ei->attackedBy[us][0] & pos.pieces_of_color(them)) == 0 - && !ei->mi->specialized_eval_exists() - && (pos.ep_square() == SQ_NONE) - && !pos.has_pawn_on_7th(us); - if (p.is_check()) phaseIndex = EvasionsPhaseIndex; else if (depth > Depth(0)) phaseIndex = MainSearchPhaseIndex; else if (depth == Depth(0)) - phaseIndex = (noCaptures ? QsearchNoCapturesPhaseIndex : QsearchWithChecksPhaseIndex); + phaseIndex = QsearchWithChecksPhaseIndex; else - phaseIndex = (noCaptures ? NoMovesPhaseIndex : QsearchWithoutChecksPhaseIndex); + phaseIndex = QsearchWithoutChecksPhaseIndex; + + Color us = pos.side_to_move(); dc = p.discovered_check_candidates(us); - pinned = p.pinned_pieces(p.side_to_move()); + pinned = p.pinned_pieces(us); finished = false; } @@ -130,7 +120,7 @@ Move MovePicker::get_next_move() { if (ttMove != MOVE_NONE) { assert(move_is_ok(ttMove)); - if (move_is_legal(pos, ttMove)) + if (move_is_legal(pos, ttMove, pinned)) return ttMove; } break; @@ -139,10 +129,10 @@ Move MovePicker::get_next_move() { if (mateKiller != MOVE_NONE) { assert(move_is_ok(mateKiller)); - if (move_is_legal(pos, mateKiller)) + if (move_is_legal(pos, mateKiller, pinned)) return mateKiller; - } - break; + } + break; case PH_GOOD_CAPTURES: numOfMoves = generate_captures(pos, moves); @@ -162,7 +152,7 @@ Move MovePicker::get_next_move() { case PH_EVASIONS: assert(pos.is_check()); - numOfMoves = generate_evasions(pos, moves); + numOfMoves = generate_evasions(pos, moves, pinned); score_evasions(); movesPicked = 0; break; @@ -174,7 +164,7 @@ Move MovePicker::get_next_move() { break; case PH_QCHECKS: - numOfMoves = generate_checks(pos, moves); + numOfMoves = generate_checks(pos, moves, dc); movesPicked = 0; break; @@ -394,7 +384,7 @@ Move MovePicker::pick_move_from_list() { moves[bestIndex] = moves[movesPicked++]; if ( move != ttMove && move != mateKiller - && pos.pl_move_is_legal(move)) + && pos.pl_move_is_legal(move, pinned)) return move; } break; @@ -414,7 +404,7 @@ Move MovePicker::pick_move_from_list() { moves[bestIndex] = moves[movesPicked++]; if ( move != ttMove && move != mateKiller - && pos.pl_move_is_legal(move)) + && pos.pl_move_is_legal(move, pinned)) return move; } break; @@ -442,7 +432,7 @@ Move MovePicker::pick_move_from_list() { move = badCaptures[movesPicked++].move; if ( move != ttMove && move != mateKiller - && pos.pl_move_is_legal(move)) + && pos.pl_move_is_legal(move, pinned)) return move; } break; @@ -457,7 +447,7 @@ Move MovePicker::pick_move_from_list() { moves[bestIndex] = moves[movesPicked++]; // Remember to change the line below if we decide to hash the qsearch! // Maybe also postpone the legality check until after futility pruning? - if (/* move != ttMove && */ pos.pl_move_is_legal(move)) + if (/* move != ttMove && */ pos.pl_move_is_legal(move, pinned)) return move; } break; @@ -471,7 +461,7 @@ Move MovePicker::pick_move_from_list() { { move = moves[movesPicked++].move; // Remember to change the line below if we decide to hash the qsearch! - if (/* move != ttMove && */ pos.pl_move_is_legal(move)) + if (/* move != ttMove && */ pos.pl_move_is_legal(move, pinned)) return move; } break; @@ -525,17 +515,9 @@ void MovePicker::init_phase_table() { PhaseTable[i++] = PH_QCHECKS; PhaseTable[i++] = PH_STOP; - // Quiescence search with checks only and no captures - QsearchNoCapturesPhaseIndex = i - 1; - PhaseTable[i++] = PH_QCHECKS; - PhaseTable[i++] = PH_STOP; - // Quiescence search without checks QsearchWithoutChecksPhaseIndex = i - 1; PhaseTable[i++] = PH_QCAPTURES; PhaseTable[i++] = PH_STOP; - // Do not generate any move - NoMovesPhaseIndex = i - 1; - PhaseTable[i++] = PH_STOP; }