-/// next_move() is the most important method of the MovePicker class. It returns
-/// a new pseudo legal move every time is called, until there are no more moves
-/// left. It picks the move with the biggest score from a list of generated moves
-/// taking care not returning the ttMove if has already been searched previously.
-template<>
-Move MovePicker::next_move<false>() {
-
- Move move;
-
- while (true)
- {
- while (cur == end)
- generate_next();
-
- switch (stage) {
-
- case MAIN_SEARCH: case EVASION: case QSEARCH_0: case QSEARCH_1: case PROBCUT:
- cur++;
- return ttMove;
-
- case CAPTURES_S1:
- move = pick_best(cur++, end)->move;
- if (move != ttMove)
- {
- if (pos.see_sign(move) >= 0)
- return move;
-
- // Losing capture, move it to the tail of the array
- (endBadCaptures--)->move = move;
- }
- break;
-
- case KILLERS_S1:
- move = (cur++)->move;
- if ( move != MOVE_NONE
- && pos.is_pseudo_legal(move)
- && move != ttMove
- && !pos.is_capture(move))
- return move;
- break;
-
- case QUIETS_1_S1: case QUIETS_2_S1:
- move = (cur++)->move;
- if ( move != ttMove
- && move != killers[0].move
- && move != killers[1].move
- && move != killers[2].move
- && move != killers[3].move)
- return move;
- break;
-
- case BAD_CAPTURES_S1:
- return (cur--)->move;
-
- case EVASIONS_S2: case CAPTURES_S3: case CAPTURES_S4:
- move = pick_best(cur++, end)->move;
- if (move != ttMove)
- return move;
- break;
-
- case CAPTURES_S5:
- move = pick_best(cur++, end)->move;
- if (move != ttMove && pos.see(move) > captureThreshold)
- return move;
- break;
-
- case CAPTURES_S6:
- move = pick_best(cur++, end)->move;
- if (to_sq(move) == recaptureSquare)
- return move;
- break;
-
- case QUIET_CHECKS_S3:
- move = (cur++)->move;
- if (move != ttMove)
- return move;
- break;
-
- case STOP:
- return MOVE_NONE;
-
- default:
- assert(false);
- }
- }