+ it->score = H.value(pos.piece_moved(m), to_sq(m));
+ }
+}
+
+
+/// MovePicker::generate_next() generates, scores and sorts the next bunch of moves,
+/// when there are no more moves to try for the current phase.
+
+void MovePicker::generate_next() {
+
+ cur = moves;
+
+ switch (++phase) {
+
+ case CAPTURES_S1: case CAPTURES_S3: case CAPTURES_S4: case CAPTURES_S5: case CAPTURES_S6:
+ end = generate<CAPTURES>(pos, moves);
+ score_captures();
+ return;
+
+ case KILLERS_S1:
+ cur = killers;
+ end = cur + 2;
+ return;
+
+ case QUIETS_1_S1:
+ endQuiets = end = generate<QUIETS>(pos, moves);
+ score_noncaptures();
+ end = std::partition(cur, end, has_positive_score);
+ sort<MoveStack>(cur, end);
+ return;
+
+ case QUIETS_2_S1:
+ cur = end;
+ end = endQuiets;
+ if (depth >= 3 * ONE_PLY)
+ sort<MoveStack>(cur, end);
+ return;
+
+ case BAD_CAPTURES_S1:
+ // Just pick them in reverse order to get MVV/LVA ordering
+ cur = moves + MAX_MOVES - 1;
+ end = endBadCaptures;
+ return;
+
+ case EVASIONS_S2:
+ end = generate<EVASIONS>(pos, moves);
+ score_evasions();
+ return;
+
+ case QUIET_CHECKS_S3:
+ end = generate<QUIET_CHECKS>(pos, moves);
+ return;
+
+ case EVASION: case QSEARCH_0: case QSEARCH_1: case PROBCUT: case RECAPTURE:
+ phase = STOP;
+ case STOP:
+ end = cur + 1; // Avoid another next_phase() call
+ return;
+
+ default:
+ assert(false);