- const MovegenPhaseT MainSearchPhaseTable[] = { PH_TT_MOVES, PH_GOOD_CAPTURES, PH_KILLERS, PH_NONCAPTURES, PH_BAD_CAPTURES, PH_STOP};
- const MovegenPhaseT EvasionsPhaseTable[] = { PH_EVASIONS, PH_STOP};
- const MovegenPhaseT QsearchWithChecksPhaseTable[] = { PH_TT_MOVES, PH_QCAPTURES, PH_QCHECKS, PH_STOP};
- const MovegenPhaseT QsearchWithoutChecksPhaseTable[] = { PH_TT_MOVES, PH_QCAPTURES, PH_STOP};
+ const uint8_t MainSearchTable[] = { PH_TT_MOVE, PH_GOOD_CAPTURES, PH_KILLERS, PH_NONCAPTURES_1, PH_NONCAPTURES_2, PH_BAD_CAPTURES, PH_STOP };
+ const uint8_t EvasionTable[] = { PH_TT_MOVE, PH_EVASIONS, PH_STOP };
+ const uint8_t QsearchWithChecksTable[] = { PH_TT_MOVE, PH_QCAPTURES, PH_QCHECKS, PH_STOP };
+ const uint8_t QsearchWithoutChecksTable[] = { PH_TT_MOVE, PH_QCAPTURES, PH_STOP };
+ const uint8_t QsearchRecapturesTable[] = { PH_TT_MOVE, PH_QRECAPTURES, PH_STOP };
+ const uint8_t ProbCutTable[] = { PH_TT_MOVE, PH_GOOD_PROBCUT, PH_STOP };
+
+ // 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 pushes to the front the best move in 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;
+ }