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


C# Position.capture方法代码示例

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


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

示例1: qsearch


//.........这里部分代码省略.........
        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,
                    depth - Depth.ONE_PLY);
            pos.undo_move(move);

            Debug.Assert(value > -Value.VALUE_INFINITE && value < Value.VALUE_INFINITE);

            // Check for new best move
            if (value <= bestValue) continue;

            bestValue = value;

            if (value > alpha)
            {
                if (PvNode) // Update pv even in fail-high case
                    update_pv(currentStack.pv, move, nextStack.pv);

                if (PvNode && value < beta) // Update alpha here! Always alpha < beta
                {
                    alpha = value;
                    bestMove = move;
                }
                else // Fail high
                {
                    tte.save(posKey, value_to_tt(value, currentPly), Bound.BOUND_LOWER,
                        ttDepth, move, currentStack.staticEval, TranspositionTable.generation());

                    return value;
                }
            }
        }

        // All legal moves have been searched. A special case: If we're in check
        // and no legal moves were found, it is checkmate.
        if (InCheck && bestValue == -Value.VALUE_INFINITE)
            return Value.mated_in(currentPly); // Plies to mate from the root

        tte.save(posKey, value_to_tt(bestValue, currentPly),
            PvNode && bestValue > oldAlpha ? Bound.BOUND_EXACT : Bound.BOUND_UPPER,
            ttDepth, bestMove, ss[ss.current].staticEval, TranspositionTable.generation());

        Debug.Assert(bestValue > -Value.VALUE_INFINITE && bestValue < Value.VALUE_INFINITE);

        return bestValue;
    }
开发者ID:torfranz,项目名称:NetFish,代码行数:101,代码来源:Search.cs

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