+ switch (phase) {
+
+ case PH_TT_MOVES:
+ move = (curMove++)->move;
+ if ( move != MOVE_NONE
+ && move_is_legal(pos, move, pinned))
+ return move;
+ break;
+
+ case PH_GOOD_CAPTURES:
+ move = pick_best(curMove++, lastMove).move;
+ if ( move != ttMoves[0].move
+ && move != ttMoves[1].move
+ && pos.pl_move_is_legal(move, pinned))
+ {
+ // Check for a non negative SEE now
+ int seeValue = pos.see_sign(move);
+ if (seeValue >= badCaptureThreshold)
+ return move;
+
+ // Losing capture, move it to the tail of the array, note
+ // that move has now been already checked for legality.
+ (--badCaptures)->move = move;
+ badCaptures->score = seeValue;
+ }
+ break;
+
+ case PH_KILLERS:
+ move = (curMove++)->move;
+ if ( move != MOVE_NONE
+ && move_is_legal(pos, move, pinned)
+ && move != ttMoves[0].move
+ && move != ttMoves[1].move
+ && !pos.move_is_capture(move))
+ return move;
+ break;
+
+ case PH_NONCAPTURES:
+
+ // Sort negative scored moves only when we get there
+ if (curMove == lastGoodNonCapture)
+ insertion_sort(lastGoodNonCapture, lastMove);
+
+ move = (curMove++)->move;
+ if ( move != ttMoves[0].move
+ && move != ttMoves[1].move
+ && move != killers[0].move
+ && move != killers[1].move
+ && pos.pl_move_is_legal(move, pinned))
+ return move;
+ break;
+
+ case PH_BAD_CAPTURES:
+ move = pick_best(curMove++, lastMove).move;