-/// MovePicker::next_phase() generates, scores and sorts the next bunch of moves,
-/// when there are no more moves to try for the current phase.
-
-void MovePicker::next_phase() {
-
- curMove = moves;
-
- switch (++phase) {
-
- case TT_MOVE_S1: case TT_MOVE_S2: case TT_MOVE_S3: case TT_MOVE_S4: case TT_MOVE_S5:
- lastMove = curMove + 1;
- return;
-
- case GOOD_CAPTURES_S1:
- case CAPTURES_S3: case CAPTURES_S4: case CAPTURES_S5:
- case RECAPTURES_S6:
- lastMove = generate<MV_CAPTURE>(pos, moves);
- score_captures();
- return;
-
- case KILLERS_S1:
- curMove = killers;
- lastMove = curMove + 2;
- return;
-
- case NONCAPTURES_1_S1:
- lastNonCapture = lastMove = generate<MV_NON_CAPTURE>(pos, moves);
- score_noncaptures();
- lastMove = std::partition(curMove, lastMove, has_positive_score);
- sort<MoveStack>(curMove, lastMove);
- return;
-
- case NONCAPTURES_2_S1:
- curMove = lastMove;
- lastMove = lastNonCapture;
- if (depth >= 3 * ONE_PLY)
- sort<MoveStack>(curMove, lastMove);
- return;
-
- case BAD_CAPTURES_S1:
- // Bad captures SEE value is already calculated so just pick them in order
- // to get SEE move ordering.
- curMove = badCaptures;
- lastMove = moves + MAX_MOVES;
- 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);
- return;
-
- case STOP_S1: case STOP_S2: case STOP_S3: case STOP_S4: case STOP_S5: case STOP_S6:
- lastMove = curMove + 1; // Avoid another next_phase() call
- return;
-
- default:
- assert(false);
- }
-}