- /// Variables
-
- MovePicker::MovegenPhase PhaseTable[32];
- int MainSearchPhaseIndex;
- int EvasionsPhaseIndex;
- int QsearchWithChecksPhaseIndex;
- int QsearchWithoutChecksPhaseIndex;
-
+ enum Sequencer {
+ MAIN_SEARCH, TT_MOVE_S1, CAPTURES_S1, KILLERS_S1, QUIETS_1_S1,
+ QUIETS_2_S1, BAD_CAPTURES_S1, STOP_S1,
+ EVASIONS, TT_MOVE_S2, EVASIONS_S2, STOP_S2,
+ CAPTURES_AND_CHECKS, TT_MOVE_S3, CAPTURES_S3, QUIET_CHECKS_S3, STOP_S3,
+ CAPTURES, TT_MOVE_S4, CAPTURES_S4, STOP_S4,
+ PROBCUT, TT_MOVE_S5, CAPTURES_S5, STOP_S5,
+ RECAPTURES, CAPTURES_S6, STOP_S6
+ };
+
+ // Unary predicate used by std::partition to split positive scores from remaining
+ // ones so to sort separately the two sets, and with the second sort delayed.
+ inline bool has_positive_score(const MoveStack& move) { return move.score > 0; }
+
+ // Picks and moves to the front the best move in the range [firstMove, lastMove),
+ // it is faster than sorting all the moves in advance when moves are few, as
+ // normally are the possible captures.
+ inline MoveStack* pick_best(MoveStack* firstMove, MoveStack* lastMove)
+ {
+ std::swap(*firstMove, *std::max_element(firstMove, lastMove));
+ return firstMove;
+ }