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


C# Skill.enabled方法代码示例

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


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

示例1: id_loop

    // id_loop() is the main iterative deepening loop. It calls search() repeatedly
    // with increasing depth until the allocated thinking time has been consumed,
    // user stops the search, or the maximum search depth is reached.

    private static void id_loop(Position pos)
    {
        var stack = new Stack[_.MAX_PLY + 4];
        for (var idx = 0; idx < stack.Length; idx++)
        {
            stack[idx] = new Stack();
        }

        var ss = new StackArrayWrapper(stack, 2); // To allow referencing (ss-2) and (ss+2)

        ValueT alpha, delta;

        var easyMove = EasyMove.get(pos.key());
        EasyMove.clear();

        //TODO: need to memset?
        //Math.Memset(ss - 2, 0, 5 * sizeof(Stack));

        var depth = Depth.DEPTH_ZERO;
        BestMoveChanges = 0;
        var bestValue = delta = alpha = -Value.VALUE_INFINITE;
        var beta = Value.VALUE_INFINITE;

        TranspositionTable.new_search();

        var multiPV = uint.Parse(OptionMap.Instance["MultiPV"].v);
        var skill = new Skill(int.Parse(OptionMap.Instance["Skill Level"].v));

        // When playing with strength handicap enable MultiPV search that we will
        // use behind the scenes to retrieve a set of possible moves.
        if (skill.enabled())
        {
            multiPV = Math.Max(multiPV, 4);
            multiPV = Math.Max(multiPV, 4);
            multiPV = Math.Max(multiPV, 4);
        }

        multiPV = (uint) Math.Min(multiPV, RootMoves.Count);

        // Iterative deepening loop until requested to stop or target depth reached;
        while (++depth < _.MAX_PLY && !Signals.stop && (Limits.depth == 0 || depth <= Limits.depth))
        {
            // Age out PV variability metric
            BestMoveChanges *= 0.5;

            // Save the last iteration's scores before first PV line is searched and
            // all the move scores except the (new) PV are set to -VALUE_INFINITE.
            foreach (var rm in RootMoves)
            {
                rm.previousScore = rm.score;
            }

            // MultiPV loop. We perform a full root search for each PV line
            for (PVIdx = 0; PVIdx < multiPV && !Signals.stop; ++PVIdx)
            {
                // Reset aspiration window starting size
                if (depth >= 5*Depth.ONE_PLY_C)
                {
                    delta = Value.Create(16);
                    alpha = Value.Create(Math.Max(RootMoves[(int) PVIdx].previousScore - delta, -Value.VALUE_INFINITE));
                    beta = Value.Create(Math.Min(RootMoves[(int) PVIdx].previousScore + delta, Value.VALUE_INFINITE));
                }

                // Start with a small aspiration window and, in the case of a fail
                // high/low, re-search with a bigger window until we're not failing
                // high/low anymore.
                while (true)
                {
                    bestValue = search(NodeType.Root, false, pos, ss, alpha, beta, depth, false);

                    // Bring the best move to the front. It is critical that sorting
                    // is done with a stable algorithm because all the values but the
                    // first and eventually the new best one are set to -VALUE_INFINITE
                    // and we want to keep the same order for all the moves except the
                    // new PV that goes to the front. Note that in case of MultiPV
                    // search the already searched PV lines are preserved.

                    //TODO: Check for stable sort replacement
                    Utils.stable_sort(RootMoves, (int) PVIdx, RootMoves.Count);
                    //std::stable_sort(RootMoves.begin() + PVIdx, RootMoves.end());

                    // Write PV back to transposition table in case the relevant
                    // entries have been overwritten during the search.
                    for (var i = 0; i <= PVIdx; ++i)
                    {
                        RootMoves[i].insert_pv_in_tt(pos);
                    }

                    // If search has been stopped break immediately. Sorting and
                    // writing PV back to TT is safe because RootMoves is still
                    // valid, although it refers to previous iteration.
                    if (Signals.stop)
                    {
                        break;
                    }

//.........这里部分代码省略.........
开发者ID:torfranz,项目名称:NetFish,代码行数:101,代码来源:Search.cs


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