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


C# SearchResult.GetDepth方法代码示例

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


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

示例1: PrintMoveStatistics

        private void PrintMoveStatistics(double runtime, Grid grid, SearchResult result,
            int[] scores, int[] scoreTypes)
        {
            Debug.Assert(scores.Length == scoreTypes.Length);

            log.WriteLine("Done");

            // Print the grid before the AI's move to the log file.
            log.WriteLineToLog();
            log.WriteLineToLog("Grid before AI move:");
            log.WriteLineToLog(grid.ToString());
            log.WriteLineToLog();

            // Print node statistics.
            double cutoffsOnFirstChild = betaCutoffsOnFirstChild * 100D / betaCutoffs;
            double cutoffsOnOrderedChildren = betaCutoffsOnOrderedChildren * 100D / betaCutoffs;
            log.Write("Analysed ");
            WriteWithColor("{0:N0}", ConsoleColor.White, totalNodesSearched);
            log.WriteLine(" states, including {0:N0} end states.", endNodesSearched);
            log.WriteLine("   Searched {0:N0} pv-nodes, {1:N0} cut-nodes and {2:N0} all-nodes.",
                pvNodes, cutNodes, allNodes);
            log.WriteLine("   {0:N0} cutoffs from lookups.", alphaBetaCutoffs);
            log.WriteLine("   {0:N0} beta cutoffs ({1:N2}% on first child, {2:N2}% on "
                + "ordered children).", betaCutoffs, cutoffsOnFirstChild,
                cutoffsOnOrderedChildren);

            // Print runtime statistics.
            double nodesPerMillisecond = Math.Round(totalNodesSearched / runtime, 4);
            string minutes = (runtime > 60000)
                ? String.Format(" ({0:N2} minutes)", runtime / 60000.0) : "";
            log.Write("Runtime {0:N} ms{1} (", runtime, minutes);
            WriteWithColor("{0:N}", ConsoleColor.White, nodesPerMillisecond);
            log.WriteLine(" states / ms).");
            log.WriteLine("   Total runtime {0:N} ms.", totalRuntime);

            // Print the scores of each valid move.
            log.Write("The move scores are");
            for (int i = 0; i < scores.Length; i++)
            {
                if (grid.IsValidMove(i))
                {
                    log.Write("  {0}:", i);

                    if (scoreTypes[i] == -1)
                    {
                        log.Write("-");
                    }

                    else
                    {
                        if (scores[i] == infinity)
                        {
                            log.WriteToLog("+\u221E");
                            Console.ForegroundColor = ConsoleColor.Green;
                            Console.Write("+Inf");
                            Console.ResetColor();
                        }

                        else if (scores[i] == -infinity)
                        {
                            log.WriteToLog("-\u221E");
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.Write("-Inf");
                            Console.ResetColor();
                        }

                        else
                        {
                            log.Write("{0}", scores[i]);
                        }

                        switch (scoreTypes[i])
                        {
                            case NodeTypeExact:
                                log.Write("E");
                                break;
                            case NodeTypeLower:
                                log.Write("L");
                                break;
                            case NodeTypeUpper:
                                log.Write("U");
                                break;
                        }
                    }
                }
            }

            log.WriteLine();

            // Print the score of the chosen move.
            if (result.score > 0)
            {
                WriteLineWithColor("   AI will win latest on move {0}.",
                    ConsoleColor.Green, result.GetDepth());
            }
            else if (result.score < 0)
            {
                WriteLineWithColor("   AI will lose on move {0} (assuming perfect play).",
                    ConsoleColor.Red, result.GetDepth());
            }
//.........这里部分代码省略.........
开发者ID:ChristopheSteininger,项目名称:Connect4,代码行数:101,代码来源:AIPlayer.cs


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