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


C# GameEngine.StartGame方法代码示例

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


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

示例1: Main

        public static void Main(string[] args)
        {
            const int GAMES_TO_PLAY = 1000;

            string[] names = {"joe", "bob"};
            string[] decklists = {"20 Goblin Piker\n20 Grey Ogre\n20 Mountain",
                "20 Grey Ogre\n15 Hill Giant\n25 Mountain"
            };
            Dictionary<string,int> wins = new Dictionary<string, int>();
            Dictionary<string,int> winsOnPlay = new Dictionary<string, int>();
            foreach(var s in names)
            {
                wins[s] = 0;
                winsOnPlay[s] = 0;
            }

            logger.Info("mlaSharp : Magic the Gathering Learning Agent");
            for(int iterations = 0; iterations< GAMES_TO_PLAY; iterations++)
            {
                GameEngine env = new GameEngine();
                for(int i = 0; i < 2; i++)
                {
            #if RANDOM_PLAYERS
                    Player player = new RandomPlayer(env,env.rng,names[i]);
            #elif MCTS_PLAYERS
                    Player player = new MctsPlayer(env,names[i]);
            #else
            //					Console.WriteLine("Player " + i + " name: ");
            //					Console.Write("mla> ");
            //					string name = Console.In.ReadLine();
                    Player player = new ConsolePlayer(env,names[i]);
            #endif

            #if INPUT_DECKLISTS
                    Console.Write("Decklist path:\nmla> ");
                    string decklistPath = Console.In.ReadLine ();
            #else
                    string decklistPath = null;
            #endif
                    Library lib = null;
                    if(String.IsNullOrEmpty(decklistPath))
                    {
                        lib = Library.ParseDecklist(decklists[i],player);
                    }
                    else
                    {
                        throw new NotImplementedException("Custom decklists not currently implemented");
                    }

                    env.AddPlayer(player,lib);
                    logger.Debug("Player " + player.Name + " created!");
                }
                Player winner = env.StartGame();
                if(winner != null)
                {
                    wins[winner.Name]++;
                    if(winner == env.StartingPlayer)
                    {
                        winsOnPlay[winner.Name]++;
                    }
                }
            }

            foreach(var s in wins.Keys)
            {
                int winsCount, winsOnPlayCount;
                double winPercent, winOnPlayPercent;
                winsCount = wins[s];
                winsOnPlayCount = winsOnPlay[s];
                winPercent = (double)winsCount / GAMES_TO_PLAY;
                winOnPlayPercent = (double)winsOnPlayCount / winsCount;
                logger.Info(String.Format("Player {0} won {1} times ({2:f2}%), {3} times on the play ({4:f2}%).",s,winsCount,winPercent,winsOnPlayCount,winOnPlayPercent));
            }
        }
开发者ID:greg-mitchell,项目名称:mlaSharp,代码行数:74,代码来源:Main.cs


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