-/// Constructor for the MovePicker class. Apart from the position for which
-/// it is asked to pick legal moves, MovePicker also wants some 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, SearchStack* ss) : pos(p), H(h) {
- ttMove = ttm;
- if (ss)
- {
- mateKiller = (ss->mateKiller == ttm)? MOVE_NONE : ss->mateKiller;
- killer1 = ss->killers[0];
- killer2 = ss->killers[1];
- } else
- mateKiller = killer1 = killer2 = MOVE_NONE;
-
- movesPicked = numOfMoves = numOfBadCaptures = 0;
- checkKillers = checkLegal = finished = false;
-
- if (p.is_check())
- phaseIndex = EvasionsPhaseIndex;
- else if (d > Depth(0))
- phaseIndex = MainSearchPhaseIndex;
- else if (d == Depth(0))
- phaseIndex = QsearchWithChecksPhaseIndex;
- else
- phaseIndex = QsearchWithoutChecksPhaseIndex;
-
- Color us = pos.side_to_move();
-
- dc = p.discovered_check_candidates(us);
- pinned = p.pinned_pieces(us);
-
- finished = false;
-}
-
-
-/// MovePicker::get_next_move() is the most important method of the MovePicker
-/// class. It returns a new legal move every time it is called, until there
-/// are no more moves left of the types we are interested in.
-
-Move MovePicker::get_next_move() {
-
- Move move;
-
- while (true)
- {
- // If we already have a list of generated moves, pick the best move from
- // the list, and return it.
- move = pick_move_from_list();
- if (move != MOVE_NONE)
- {
- assert(move_is_ok(move));
- return move;
- }
-
- // Next phase
- phaseIndex++;
- switch (PhaseTable[phaseIndex]) {
-
- case PH_TT_MOVE:
- if (ttMove != MOVE_NONE)
- {
- assert(move_is_ok(ttMove));
- if (move_is_legal(pos, ttMove, pinned))
- return ttMove;
- }
- break;