当前位置: 首页>>代码示例>>C#>>正文


C# Position.see方法代码示例

本文整理汇总了C#中Position.see方法的典型用法代码示例。如果您正苦于以下问题:C# Position.see方法的具体用法?C# Position.see怎么用?C# Position.see使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Position的用法示例。


在下文中一共展示了Position.see方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: qsearch


//.........这里部分代码省略.........
        // queen promotions and checks (only if depth >= DEPTH_QS_CHECKS) will
        // be generated.
        var mp = new MovePicker(pos, ttMove, depth, History, CounterMovesHistory,
            Move.to_sq(previousStack.currentMove));
        var ci = new CheckInfo(pos);

        // Loop through the moves until no moves remain or a beta cutoff occurs
        MoveT move;
        MoveT bestMove = Move.MOVE_NONE;
        while ((move = mp.next_move(false)) != Move.MOVE_NONE)
        {
            Debug.Assert(Move.is_ok(move));

            var givesCheck = Move.type_of(move) == MoveType.NORMAL && ci.dcCandidates == 0
                ? Bitboard.AndWithSquare(ci.checkSquares[Piece.type_of(pos.piece_on(Move.from_sq(move)))], Move.to_sq(move))!=0
                : pos.gives_check(move, ci);

            // Futility pruning
            if (!InCheck
                && !givesCheck
                && futilityBase > -Value.VALUE_KNOWN_WIN
                && !pos.advanced_pawn_push(move))
            {
                Debug.Assert(Move.type_of(move) != MoveType.ENPASSANT); // Due to !pos.advanced_pawn_push

                var futilityValue = futilityBase + Value.PieceValue[(int) Phase.EG][pos.piece_on(Move.to_sq(move))];

                if (futilityValue <= alpha)
                {
                    bestValue = Value.Create(Math.Max(bestValue, futilityValue));
                    continue;
                }

                if (futilityBase <= alpha && pos.see(move) <= Value.VALUE_ZERO)
                {
                    bestValue = Value.Create(Math.Max(bestValue, futilityBase));
                    continue;
                }
            }

            // Detect non-capture evasions that are candidates to be pruned
            var evasionPrunable = InCheck
                                   && bestValue > Value.VALUE_MATED_IN_MAX_PLY
                                   && !pos.capture(move);

            // Don't search moves with negative SEE values
            if ((!InCheck || evasionPrunable)
                && Move.type_of(move) != MoveType.PROMOTION
                && pos.see_sign(move) < Value.VALUE_ZERO)
                continue;

            // Speculative prefetch as early as possible
            //prefetch(TT.first_entry(pos.key_after(move)));

            // Check for legality just before making the move
            if (!pos.legal(move, ci.pinned))
                continue;

            ss[ss.current].currentMove = move;

            // Make and search the move
            pos.do_move(move, new StateInfo(), givesCheck);
            var value = givesCheck
                ? -qsearch(NT, true, pos, new StackArrayWrapper(ss.table, ss.current + 1), -beta, -alpha,
                    depth - Depth.ONE_PLY)
                : -qsearch(NT, false, pos, new StackArrayWrapper(ss.table, ss.current + 1), -beta, -alpha,
开发者ID:torfranz,项目名称:NetFish,代码行数:67,代码来源:Search.cs

示例2: search


//.........这里部分代码省略.........
            
            if (SpNode)
            {
                // Shared counter cannot be decremented later if the move turns out to be illegal
                if (!pos.legal(move, ci.pinned))
                    continue;

                stack.moveCount = moveCount = ++splitPoint.moveCount;
                ThreadHelper.lock_release(splitPoint.spinLock);
            }
            else
                stack.moveCount = ++moveCount;

            if (RootNode)
            {
                Signals.firstRootMove = (moveCount == 1);

                if (thisThread == ThreadPool.main() && TimeManagement.elapsed() > 3000)
                    Output.WriteLine(
                        $"info depth {depth/Depth.ONE_PLY} currmove {UCI.move(move, pos.is_chess960())} currmovenumber {moveCount + PVIdx}");
            }

            if (PvNode)
                stackPlus1.pv = new List<MoveT>();

            var extension = Depth.DEPTH_ZERO;
            var captureOrPromotion = pos.capture_or_promotion(move);

            var givesCheck = Move.type_of(move) == MoveType.NORMAL && ci.dcCandidates == 0
                ? Bitboard.AndWithSquare(ci.checkSquares[Piece.type_of(pos.piece_on(Move.from_sq(move)))], Move.to_sq(move))!=0
                : pos.gives_check(move, ci);

            // Step 12. Extend checks
            if (givesCheck && pos.see_sign(move) >= Value.VALUE_ZERO)
                extension = Depth.ONE_PLY;

            // Singular extension search. If all moves but one fail low on a search of
            // (alpha-s, beta-s), and just one fails high on (alpha, beta), then that move
            // is singular and should be extended. To verify this we do a reduced search
            // on all the other moves but the ttMove and if the result is lower than
            // ttValue minus a margin then we extend the ttMove.
            if (singularExtensionNode
                && move == ttMove
                && extension == 0
                && pos.legal(move, ci.pinned))
            {
                var rBeta = ttValue - 2*depth/Depth.ONE_PLY;
                stack.excludedMove = move;
                stack.skipEarlyPruning = true;
                value = search(NodeType.NonPV, false, pos, ss, rBeta - 1, rBeta, depth/2, cutNode);
                stack.skipEarlyPruning = false;
                stack.excludedMove = Move.MOVE_NONE;

                if (value < rBeta)
                    extension = Depth.ONE_PLY;
            }

            // Update the current move (this must be done after singular extension search)
            var newDepth = depth - Depth.ONE_PLY + extension;

            // Step 13. Pruning at shallow depth
            if (!RootNode
                && !captureOrPromotion
                && !inCheck
                && !givesCheck
                && !pos.advanced_pawn_push(move)
开发者ID:torfranz,项目名称:NetFish,代码行数:67,代码来源:Search.cs

示例3: MovePicker

    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;
    }
开发者ID:torfranz,项目名称:NetFish,代码行数:23,代码来源:Movepicker.cs


注:本文中的Position.see方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。