- CACHE_LINE_ALIGNMENT
- 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;
+ // partial_insertion_sort() sorts moves in descending order up to and including
+ // a given limit. The order of moves smaller than the limit is left unspecified.
+ void partial_insertion_sort(ExtMove* begin, ExtMove* end, int limit) {
+
+ for (ExtMove *sortedEnd = begin, *p = begin + 1; p < end; ++p)
+ if (p->value >= limit)
+ {
+ ExtMove tmp = *p, *q;
+ *p = *++sortedEnd;
+ for (q = sortedEnd; q != begin && *(q - 1) < tmp; --q)
+ *q = *(q - 1);
+ *q = tmp;
+ }