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


C# IPlayer.Fill方法代码示例

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


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

示例1: RunAITournament

 public static void RunAITournament(int numPlayers, int round)
 {
     DateTime startTime = DateTime.Now;
     var stats = new Dictionary<string, TournamentPlayerStats>();
     var simplexLearnedScores = SimplexLearnedScores.Load(SimplexLearning.FileName);
     ColorConsole.WriteLine(ConsoleColor.Cyan, "Loaded parameters: {0}", simplexLearnedScores);
     for (int i = 1; i <= round; ++i)
     {
         var game = new Game.Game((new SettlerBoardConstructor()).ConstructBoard(), numPlayers);
         game.Round = i;
         var improvedEmmAiPlayerNormal = new ImprovedEMN(new GameScores());
         var improvedEmmAiPlayerExpansion = new ImprovedEMN(simplexLearnedScores);
         var players = new IPlayer[numPlayers];
         players.Fill(improvedEmmAiPlayerNormal);
         players[RandomGenerator.Next(numPlayers)] = improvedEmmAiPlayerExpansion;
         for (int j = 0; j < numPlayers; ++j)
         {
             string name = players[j].Name;
             if (!stats.ContainsKey(name))
             {
                 stats[name] = new TournamentPlayerStats
                                   {
                                       PlayerName = name
                                   };
             }
         }
         var controller = new GameController(new ConsoleViewer(), game, false, players);
         int winnerIndex = controller.Run();
         TournamentPlayerStats stat = stats[players[winnerIndex].Name];
         ColorConsole.WriteLine(ConsoleColor.Yellow,
                                ">>> University {0}, AI player '{1}' has won. <<<",
                                controller.Game.GetUniversityByIndex(winnerIndex).Color,
                                stat.PlayerName
             );
         stat.HasWon();
         foreach (TournamentPlayerStats statForPrint in stats.Values)
         {
             statForPrint.PrintToConsole();
         }
         ColorConsole.WriteLine(ConsoleColor.Green, "Total time taken: " + (DateTime.Now - startTime));
     }
 }
开发者ID:MingStar,项目名称:SimUniversity,代码行数:42,代码来源:Program.cs

示例2: PlayGame

 public static void PlayGame()
 {
     while (true)
     {
         var game = new Game.Game((new SettlerBoardConstructor()).ConstructBoard(), 4);
         IPlayer improvedEMM_AIPlayer = new ImprovedEMN(new GameScores());
         var players = new IPlayer[4];
         players.Fill(improvedEMM_AIPlayer);
         players[RandomGenerator.Next(4)] = _humanConsolePlayer;
         var controller = new GameController(new ConsoleViewer(), game, true, players);
         _humanConsolePlayer.GameController = controller;
         controller.Run();
         Console.WriteLine("Try again? y/n");
         ConsoleKeyInfo key = Console.ReadKey();
         Console.WriteLine();
         if (key.KeyChar == 'n')
         {
             break;
         }
     }
 }
开发者ID:MingStar,项目名称:SimUniversity,代码行数:21,代码来源:Program.cs

示例3: RunTournament

 private double RunTournament(double[] values)
 {
     DateTime startedTime = DateTime.Now;
     _learnedScores.FromResult(values);
     var stats = new Dictionary<string, TournamentPlayerStats>();
     const int numPlayers = 2;
     int round = 0;
     var tournamentResult = new TournamentResult();
     int challengerIndex = 0;
     while (round < _roundsToWinInTournament)
     {
         ++round;
         challengerIndex = (challengerIndex + 1) % numPlayers;
         var game = new Game.Game(_boardConstructor.ConstructBoard(), numPlayers) {Round = round};
         var _improvedEMM_AIPlayer_normal = new ImprovedEMN(new GameScores());
         var _improvedEMM_AIPlayer_expansion = new ImprovedEMN(_learnedScores);
         var players = new IPlayer[numPlayers];
         players.Fill(_improvedEMM_AIPlayer_normal);
         players[challengerIndex] = _improvedEMM_AIPlayer_expansion;
         for (var j = 0; j < numPlayers; ++j)
         {
             var name = players[j].Name;
             if (!stats.ContainsKey(name))
             {
                 stats[name] = new TournamentPlayerStats
                                   {
                                       PlayerName = name
                                   };
             }
         }
         var controller = new GameController(_gameViewer, game, false, players);
         var winnerIndex = controller.Run();
         var stat = stats[players[winnerIndex].Name];
         ColorConsole.WriteLine(ConsoleColor.Yellow,
                                ">>> University {0}, AI player '{1}' has won. <<<",
                                controller.Game.GetUniversityByIndex(winnerIndex).Color,
                                stat.PlayerName
             );
         stat.HasWon();
         var challengerUni = game.GetUniversityByIndex(challengerIndex);
         tournamentResult.AddRound(
             new RoundResult(game.GetScore(challengerUni),
                             winnerIndex == challengerIndex,
                             game.Universities.Where(u => u != challengerUni).Select(game.GetScore)
                 ));
         foreach (var statForPrint in stats.Values)
         {
             statForPrint.PrintToConsole();
         }
     }
     var totalScore = tournamentResult.CalculateTotalScore();
     LogInfo(_learnedScores.ToString());
     _touranmentCount++;
     var remainingTimeSpan = GetEstimatedFinishedTime();
     LogInfo("Got score: {0}. Challenger won {1} rounds. Time taken this tournament: {2}." +
         " Total time taken: {3}. Estimated finished time: {4} ({5} to go)",
         totalScore,
         tournamentResult.ChallengerWinningCount,
         DateTime.Now - startedTime,
         DateTime.Now - _learningStartedDT,
         DateTime.Now + remainingTimeSpan,
         remainingTimeSpan);
     return -totalScore; // return negative for function minimisation
 }
开发者ID:MingStar,项目名称:SimUniversity,代码行数:64,代码来源:SimplexLearning.cs


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