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


C# Skill.best_move方法代码示例

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


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

示例1: id_loop


//.........这里部分代码省略.........
                        beta = Value.Create(Math.Min(bestValue + delta, Value.VALUE_INFINITE));
                    }
                    else
                    {
                        break;
                    }

                    delta += delta/2;

                    Debug.Assert(alpha >= -Value.VALUE_INFINITE && beta <= Value.VALUE_INFINITE);
                }

                // Sort the PV lines searched so far and update the GUI
                //TODO: Check for stable sort replacement
                Utils.stable_sort(RootMoves, 0, (int) PVIdx + 1);
                //std::stable_sort(RootMoves.begin(), RootMoves.begin() + PVIdx + 1);

                if (Signals.stop)
                {
                    Output.WriteLine($"info nodes {RootPos.nodes_searched()} time {TimeManagement.elapsed()}");
                }

                else if (PVIdx + 1 == multiPV || TimeManagement.elapsed() > 3000)
                {
                    Output.WriteLine(UCI.pv(pos, depth, alpha, beta));
                }
            }

            // If skill level is enabled and time is up, pick a sub-optimal best move
            if (skill.enabled() && skill.time_to_pick(depth))
            {
                skill.pick_best(multiPV);
            }

            // Have we found a "mate in x"?
            if (Limits.mate != 0 && bestValue >= Value.VALUE_MATE_IN_MAX_PLY
                && Value.VALUE_MATE - bestValue <= 2*Limits.mate)
            {
                Signals.stop = true;
            }

            // Do we have time for the next iteration? Can we stop searching now?
            if (Limits.use_time_management())
            {
                if (!Signals.stop && !Signals.stopOnPonderhit)
                {
                    // Take some extra time if the best move has changed
                    if (depth > 4*Depth.ONE_PLY && multiPV == 1)
                    {
                        TimeManagement.pv_instability(BestMoveChanges);
                    }

                    // Stop the search if only one legal move is available or all
                    // of the available time has been used or we matched an easyMove
                    // from the previous search and just did a fast verification.
                    if (RootMoves.Count == 1 || TimeManagement.elapsed() > TimeManagement.available()
                        || (RootMoves[0].pv[0] == easyMove && BestMoveChanges < 0.03
                            && TimeManagement.elapsed() > TimeManagement.available()/10))
                    {
                        // If we are allowed to ponder do not stop the search now but
                        // keep pondering until the GUI sends "ponderhit" or "stop".
                        if (Limits.ponder)
                        {
                            Signals.stopOnPonderhit = true;
                        }
                        else
                        {
                            Signals.stop = true;
                        }
                    }
                }

                if (RootMoves[0].pv.Count >= 3)
                {
                    EasyMove.update(pos, RootMoves[0].pv);
                }
                else
                {
                    EasyMove.clear();
                }
            }
        }

        // Clear any candidate easy move that wasn't stable for the last search
        // iterations; the second condition prevents consecutive fast moves.
        if (EasyMove.stableCnt < 6 || TimeManagement.elapsed() < TimeManagement.available())
        {
            EasyMove.clear();
        }

        // If skill level is enabled, swap best PV line with the sub-optimal one
        if (skill.enabled())
        {
            var foundIdx = RootMoves.FindIndex(rootMove1 => rootMove1.pv[0] == skill.best_move(multiPV));
            Debug.Assert(foundIdx >= 0);
            var rootMove = RootMoves[0];
            RootMoves[0] = RootMoves[foundIdx];
            RootMoves[foundIdx] = rootMove;
        }
    }
开发者ID:torfranz,项目名称:NetFish,代码行数:101,代码来源:Search.cs


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