本文整理汇总了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));
}
}
示例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;
}
}
}
示例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
}