+ // Losing capture, move it to the beginning of the array
+ *endBadCaptures++ = move;
+ }
+ }
+ ++stage;
+
+ // First killer move
+ move = ss->killers[0];
+ if ( move != MOVE_NONE
+ && move != ttMove
+ && pos.pseudo_legal(move)
+ && !pos.capture(move))
+ return move;
+
+ case KILLERS:
+ ++stage;
+ move = ss->killers[1]; // Second killer move
+ if ( move != MOVE_NONE
+ && move != ttMove
+ && pos.pseudo_legal(move)
+ && !pos.capture(move))
+ return move;
+
+ case KILLERS_2:
+ ++stage;
+ move = countermove;
+ if ( move != MOVE_NONE
+ && move != ttMove
+ && move != ss->killers[0]
+ && move != ss->killers[1]
+ && pos.pseudo_legal(move)
+ && !pos.capture(move))
+ return move;
+
+ case QUIET_INIT:
+ cur = endBadCaptures;
+ endMoves = generate<QUIETS>(pos, cur);
+ score<QUIETS>();
+ if (depth < 3 * ONE_PLY)
+ {
+ ExtMove* goodQuiet = std::partition(cur, endMoves, [](const ExtMove& m)
+ { return m.value > VALUE_ZERO; });
+ insertion_sort(cur, goodQuiet);
+ } else
+ insertion_sort(cur, endMoves);
+ ++stage;
+
+ case QUIET:
+ while (cur < endMoves)
+ {
+ move = *cur++;
+ if ( move != ttMove
+ && move != ss->killers[0]
+ && move != ss->killers[1]
+ && move != countermove)
+ return move;
+ }
+ ++stage;
+ cur = moves; // Point to beginning of bad captures
+
+ case BAD_CAPTURES:
+ if (cur < endBadCaptures)
+ return *cur++;
+ break;
+
+ case ALL_EVASIONS:
+ cur = moves;
+ endMoves = generate<EVASIONS>(pos, cur);
+ if (endMoves - cur > 1)
+ score<EVASIONS>();
+ stage = REMAINING;
+ goto remaining;
+
+ case QCAPTURES_CHECKS_INIT:
+ case QCAPTURES_NO_CHECKS:
+ cur = moves;
+ endMoves = generate<CAPTURES>(pos, cur);
+ score<CAPTURES>();
+ ++stage;
+
+remaining:
+ case QCAPTURES_CHECKS:
+ case REMAINING:
+ while (cur < endMoves)
+ {
+ move = pick_best(cur++, endMoves);
+ if (move != ttMove)
+ return move;
+ }
+ if (stage == REMAINING)
+ break;
+ cur = moves;
+ endMoves = generate<QUIET_CHECKS>(pos, cur);
+ ++stage;
+
+ case CHECKS:
+ while (cur < endMoves)
+ {
+ move = cur++->move;
+ if (move != ttMove)