- 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;
- }
-}
-
-/// Constructors for the MovePicker class. As arguments we pass information
-/// to help it to return the presumably good moves first, to decide which
-/// moves to return (in the quiescence search, for instance, we only want to
-/// search captures, promotions and some checks) and about how important good
-/// move ordering is at the current node.
-
-MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
- Search::Stack* ss, Value beta) : pos(p), H(h), depth(d) {
- captureThreshold = 0;
- badCaptures = moves + MAX_MOVES;
-
- assert(d > DEPTH_ZERO);
-
- if (p.in_check())
- {
- killers[0].move = killers[1].move = MOVE_NONE;
- phasePtr = EvasionTable;
- }
- else
- {
- killers[0].move = ss->killers[0];
- killers[1].move = ss->killers[1];
-
- // Consider sligtly negative captures as good if at low
- // depth and far from beta.
- if (ss && ss->eval < beta - PawnValueMidgame && d < 3 * ONE_PLY)
- captureThreshold = -PawnValueMidgame;
-
- phasePtr = MainSearchTable;