Exemple #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 how important good move
    /// ordering is at the current node.
    internal MovePicker(
        Position p,
        MoveT ttm,
        Depth d,
        HistoryStats h,
        CounterMovesHistoryStats cmh,
        MoveT cm,
        StackArrayWrapper s)
    {
        endBadCaptures = new ExtMoveArrayWrapper(moves, _.MAX_MOVES - 1);
        cur = new ExtMoveArrayWrapper(moves);
        endMoves = new ExtMoveArrayWrapper(moves);

        pos = p;
        history = h;
        counterMovesHistory = cmh;
        ss = s;
        countermove = cm;
        depth = d;
        Debug.Assert(d > Depth.DEPTH_ZERO);

        stage = pos.checkers() != 0 ? Stages.EVASION : Stages.MAIN_SEARCH;
        ttMove = ttm != 0 && pos.pseudo_legal(ttm) ? ttm : Move.MOVE_NONE;
        endMoves += ttMove != Move.MOVE_NONE ? 1 : 0;
    }
Exemple #2
0
    internal MovePicker(Position p, MoveT ttm, Depth d, HistoryStats h, CounterMovesHistoryStats cmh, SquareT s)
    {
        endBadCaptures = new ExtMoveArrayWrapper(moves, _.MAX_MOVES - 1);
        cur = new ExtMoveArrayWrapper(moves);
        endMoves = new ExtMoveArrayWrapper(moves);

        pos = p;
        history = h;
        counterMovesHistory = cmh;

        Debug.Assert(d <= Depth.DEPTH_ZERO_C);

        if (pos.checkers() != 0)
        {
            stage = Stages.EVASION;
        }

        else if (d > Depth.DEPTH_QS_NO_CHECKS)
        {
            stage = Stages.QSEARCH_WITH_CHECKS;
        }

        else if (d > Depth.DEPTH_QS_RECAPTURES)
        {
            stage = Stages.QSEARCH_WITHOUT_CHECKS;
        }

        else
        {
            stage = Stages.RECAPTURE;
            recaptureSquare = s;
            ttm = Move.MOVE_NONE;
        }

        ttMove = ttm != 0 && pos.pseudo_legal(ttm) ? ttm : Move.MOVE_NONE;
        endMoves += (ttMove != Move.MOVE_NONE) ? 1 : 0;
    }
Exemple #3
0
 /// Search::reset() clears all search memory, to obtain reproducible search results
 internal static void reset()
 {
     TranspositionTable.clear();
     History = new HistoryStats();
     CounterMovesHistory = new CounterMovesHistoryStats();
     Countermoves = new MovesStats();
 }
Exemple #4
0
    internal MovePicker(Position p, MoveT ttm, HistoryStats h, CounterMovesHistoryStats cmh, ValueT th)
    {
        endBadCaptures = new ExtMoveArrayWrapper(moves, _.MAX_MOVES - 1);
        cur = new ExtMoveArrayWrapper(moves);
        endMoves = new ExtMoveArrayWrapper(moves);

        pos = p;
        history = h;
        counterMovesHistory = cmh;
        threshold = th;

        Debug.Assert(pos.checkers() == 0);

        stage = Stages.PROBCUT;

        // In ProbCut we generate captures with SEE higher than the given threshold
        ttMove = ttm != 0 && pos.pseudo_legal(ttm) && pos.capture(ttm)
                 && pos.see(ttm) > threshold
            ? ttm
            : Move.MOVE_NONE;

        endMoves += (ttMove != Move.MOVE_NONE) ? 1 : 0;
    }