namespace {
enum Sequencer {
- MAIN_SEARCH, TT_MOVE_S1, GOOD_CAPTURES_S1, KILLERS_S1, NONCAPTURES_1_S1,
- NONCAPTURES_2_S1, BAD_CAPTURES_S1, STOP_S1,
+ MAIN_SEARCH, TT_MOVE_S1, CAPTURES_S1, KILLERS_S1, QUIETS_1_S1,
+ QUIETS_2_S1, BAD_CAPTURES_S1, STOP_S1,
EVASIONS, TT_MOVE_S2, EVASIONS_S2, STOP_S2,
- CAPTURES_AND_CHECKS, TT_MOVE_S3, CAPTURES_S3, CHECKS_S3, STOP_S3,
+ CAPTURES_AND_CHECKS, TT_MOVE_S3, CAPTURES_S3, QUIET_CHECKS_S3, STOP_S3,
CAPTURES, TT_MOVE_S4, CAPTURES_S4, STOP_S4,
PROBCUT, TT_MOVE_S5, CAPTURES_S5, STOP_S5,
- RECAPTURES, RECAPTURES_S6, STOP_S6
+ RECAPTURES, CAPTURES_S6, STOP_S6
};
// Unary predicate used by std::partition to split positive scores from remaining
if (p.in_check())
phase = EVASIONS;
- else if (d >= DEPTH_QS_CHECKS)
+ else if (d > DEPTH_QS_NO_CHECKS)
phase = CAPTURES_AND_CHECKS;
- else if (d >= DEPTH_QS_RECAPTURES)
+ else if (d > DEPTH_QS_RECAPTURES)
{
phase = CAPTURES;
phase += (ttMove == MOVE_NONE);
}
-MovePicker::MovePicker(const Position& p, Move ttm, const History& h, PieceType parentCapture)
- : pos(p), H(h), curMove(0), lastMove(0) {
+MovePicker::MovePicker(const Position& p, Move ttm, const History& h,
+ PieceType pt) : pos(p), H(h), curMove(0), lastMove(0) {
- assert (!pos.in_check());
+ assert(!pos.in_check());
- // In ProbCut we consider only captures better than parent's move
- captureThreshold = PieceValueMidgame[Piece(parentCapture)];
phase = PROBCUT;
- if ( ttm != MOVE_NONE
- && (!pos.is_capture(ttm) || pos.see(ttm) <= captureThreshold))
+ // In ProbCut we generate only captures better than parent's captured piece
+ captureThreshold = PieceValueMidgame[pt];
+
+ if (ttm && (!pos.is_capture(ttm) || pos.see(ttm) <= captureThreshold))
ttm = MOVE_NONE;
ttMove = (ttm && pos.is_pseudo_legal(ttm) ? ttm : MOVE_NONE);
- type_of(pos.piece_moved(m));
if (is_promotion(m))
- cur->score += PieceValueMidgame[Piece(promotion_piece_type(m))];
+ cur->score += PieceValueMidgame[promotion_piece_type(m)];
}
}
lastMove = curMove + 1;
return;
- case GOOD_CAPTURES_S1:
- case CAPTURES_S3: case CAPTURES_S4: case CAPTURES_S5:
- case RECAPTURES_S6:
+ case CAPTURES_S1: case CAPTURES_S3: case CAPTURES_S4: case CAPTURES_S5: case CAPTURES_S6:
lastMove = generate<MV_CAPTURE>(pos, moves);
score_captures();
return;
lastMove = curMove + 2;
return;
- case NONCAPTURES_1_S1:
- lastNonCapture = lastMove = generate<MV_NON_CAPTURE>(pos, moves);
+ case QUIETS_1_S1:
+ lastQuiet = lastMove = generate<MV_QUIET>(pos, moves);
score_noncaptures();
lastMove = std::partition(curMove, lastMove, has_positive_score);
sort<MoveStack>(curMove, lastMove);
return;
- case NONCAPTURES_2_S1:
+ case QUIETS_2_S1:
curMove = lastMove;
- lastMove = lastNonCapture;
+ lastMove = lastQuiet;
if (depth >= 3 * ONE_PLY)
sort<MoveStack>(curMove, lastMove);
return;
return;
case EVASIONS_S2:
- assert(pos.in_check());
lastMove = generate<MV_EVASION>(pos, moves);
score_evasions();
return;
- case CHECKS_S3:
- lastMove = generate<MV_NON_CAPTURE_CHECK>(pos, moves);
+ case QUIET_CHECKS_S3:
+ lastMove = generate<MV_QUIET_CHECK>(pos, moves);
return;
case STOP_S1: case STOP_S2: case STOP_S3: case STOP_S4: case STOP_S5: case STOP_S6:
case TT_MOVE_S1: case TT_MOVE_S2: case TT_MOVE_S3: case TT_MOVE_S4: case TT_MOVE_S5:
curMove++;
return ttMove;
- break;
- case GOOD_CAPTURES_S1:
+ case CAPTURES_S1:
move = pick_best(curMove++, lastMove)->move;
if (move != ttMove)
{
return move;
break;
- case NONCAPTURES_1_S1:
- case NONCAPTURES_2_S1:
+ case QUIETS_1_S1:
+ case QUIETS_2_S1:
move = (curMove++)->move;
if ( move != ttMove
&& move != killers[0].move
case CAPTURES_S5:
move = pick_best(curMove++, lastMove)->move;
- if ( move != ttMove
- && pos.see(move) > captureThreshold)
+ if (move != ttMove && pos.see(move) > captureThreshold)
return move;
break;
- case RECAPTURES_S6:
- move = (curMove++)->move;
+ case CAPTURES_S6:
+ move = pick_best(curMove++, lastMove)->move;
if (to_sq(move) == recaptureSquare)
return move;
break;
- case CHECKS_S3:
+ case QUIET_CHECKS_S3:
move = (curMove++)->move;
if (move != ttMove)
return move;