public void Recycle() { pos = null; H = null; mpExternal = null; }
internal void MovePickerC(Position p, Move ttm, History h, PieceType pt) { pos = p; H = h; curMovePos = 0; lastMovePos = 0; Debug.Assert(!pos.in_check()); depth = 0; ttMove = 0; lastQuietPos = 0; lastBadCapturePos = 0; mpos = 0; phase = SequencerC.PROBCUT; // In ProbCut we generate only captures better than parent's captured piece captureThreshold = Position.PieceValueMidgame[pt]; ttMove = ((ttm != 0) && pos.is_pseudo_legal(ttm) ? ttm : MoveC.MOVE_NONE); if ((ttMove != 0) && (!pos.is_capture(ttMove) || pos.see(ttMove, false) <= captureThreshold)) ttMove = MoveC.MOVE_NONE; lastMovePos += ((ttMove != MoveC.MOVE_NONE) ? 1 : 0); }
internal void MovePickerC(Position p, Move ttm, Depth d, History h, Square sq) { pos = p; H = h; curMovePos = 0; lastMovePos = 0; Debug.Assert(d <= DepthC.DEPTH_ZERO); depth = 0; recaptureSquare = 0; captureThreshold = 0; lastQuietPos = 0; lastBadCapturePos = 0; mpos = 0; if (p.in_check()) phase = SequencerC.EVASION; else if (d > DepthC.DEPTH_QS_NO_CHECKS) phase = SequencerC.QSEARCH_0; else if (d > DepthC.DEPTH_QS_RECAPTURES) { phase = SequencerC.QSEARCH_1; // Skip TT move if is not a capture or a promotion, this avoids qsearch // tree explosion due to a possible perpetual check or similar rare cases // when TT table is full. if ((ttm != 0) && !pos.is_capture_or_promotion(ttm)) ttm = MoveC.MOVE_NONE; } else { phase = SequencerC.RECAPTURE; recaptureSquare = sq; ttm = MoveC.MOVE_NONE; } ttMove = ((ttm != 0) && pos.is_pseudo_legal(ttm) ? ttm : MoveC.MOVE_NONE); lastMovePos += ((ttMove != MoveC.MOVE_NONE) ? 1 : 0); }
/// Constructors of 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. internal void MovePickerC(Position p, Move ttm, Depth d, History h, Stack ss, Value beta, MovePicker mpExt) { pos = p; H = h; depth = d; mpExternal = mpExt; Debug.Assert(d > DepthC.DEPTH_ZERO); captureThreshold = 0; curMovePos = lastMovePos = 0; lastBadCapturePos = Constants.MAX_MOVES - 1; recaptureSquare = 0; lastQuietPos = 0; mpos = 0; if (p.in_check()) { phase = SequencerC.EVASION; } else { phase = SequencerC.MAIN_SEARCH; ms[Constants.MAX_MOVES].move = ss.killers0; ms[Constants.MAX_MOVES + 1].move = ss.killers1; // Consider sligtly negative captures as good if at low depth and far from beta if (ss.eval < beta - Constants.PawnValueMidgame && d < 3 * DepthC.ONE_PLY) captureThreshold = -Constants.PawnValueMidgame; // Consider negative captures as good if still enough to reach beta else if (ss.eval > beta) captureThreshold = beta - ss.eval; } ttMove = (ttm != 0 && pos.is_pseudo_legal(ttm) ? ttm : MoveC.MOVE_NONE); lastMovePos += ((ttMove != MoveC.MOVE_NONE) ? 1 : 0); }
public void Recycle() { this.pos = null; this.H = null; this.mpExternal = null; }
internal void MovePickerC(Position p, int ttm, History h, int pt) { this.pos = p; this.H = h; this.curMovePos = 0; this.lastMovePos = 0; Debug.Assert(!this.pos.in_check()); this.depth = 0; this.ttMove = 0; this.lastQuietPos = 0; this.lastBadCapturePos = 0; this.mpos = 0; this.phase = SequencerC.PROBCUT; // In ProbCut we generate only captures better than parentSplitPoint's captured piece this.captureThreshold = Position.PieceValue[PhaseC.MG][pt]; this.ttMove = ((ttm != 0) && this.pos.is_pseudo_legal(ttm) ? ttm : MoveC.MOVE_NONE); if ((this.ttMove != 0) && (!this.pos.is_capture(this.ttMove) || this.pos.see(this.ttMove, false) <= this.captureThreshold)) { this.ttMove = MoveC.MOVE_NONE; } this.lastMovePos += ((this.ttMove != MoveC.MOVE_NONE) ? 1 : 0); }