-/// 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 HistoryStats& h, const CountermovesStats& cm,
- Search::Stack* s, Value beta) : pos(p), history(h), depth(d) {
-
- assert(d > DEPTH_ZERO);
-
- captureThreshold = 0;
- cur = end = moves;
- endBadCaptures = moves + MAX_MOVES - 1;
- ss = s;
-
- if (p.checkers())
- phase = EVASION;
-
- else
- {
- phase = MAIN_SEARCH;
-
- killers[0].move = ss->killers[0];
- killers[1].move = ss->killers[1];
- Square prevSq = to_sq((ss-1)->currentMove);
- killers[2].move = cm[pos.piece_on(prevSq)][prevSq].first;
- killers[3].move = cm[pos.piece_on(prevSq)][prevSq].second;
-
- // Consider sligtly negative captures as good if at low depth and far from beta
- if (ss && ss->staticEval < beta - PawnValueMg && d < 3 * ONE_PLY)
- captureThreshold = -PawnValueMg;
-
- // Consider negative captures as good if still enough to reach beta
- else if (ss && ss->staticEval > beta)
- captureThreshold = beta - ss->staticEval;
- }
-
- ttMove = (ttm && pos.is_pseudo_legal(ttm) ? ttm : MOVE_NONE);
- end += (ttMove != MOVE_NONE);
+/// search captures, promotions, and some checks) and how important good move
+/// ordering is at the current node.
+
+/// MovePicker constructor for the main search
+MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const ButterflyHistory* mh,
+ const CapturePieceToHistory* cph,
+ const PieceToHistory** ch,
+ Move cm,
+ const Move* killers)
+ : pos(p), mainHistory(mh), captureHistory(cph), continuationHistory(ch),
+ ttMove(ttm), refutations{{killers[0], 0}, {killers[1], 0}, {cm, 0}}, depth(d)
+{
+ assert(d > 0);
+
+ stage = (pos.checkers() ? EVASION_TT : MAIN_TT) +
+ !(ttm && pos.pseudo_legal(ttm));