public StrategyComparisonResults(StrategyComparison comparison, bool gatherStats) { this.comparison = comparison; this.statGatherer = gatherStats ? new StatsPerTurnGameLog(2, comparison.gameConfig.cardGameSubset) : null; this.winnerCount = new int[2]; this.tieCount = 0; this.maxTurnNumber = -1; this.pointSpreadHistogramData = new HistogramData(); this.gameEndOnTurnHistogramData = new HistogramData(); }
public static double ComparePlayers( object player1OrString, object player2OrString, GameConfig gameConfig, bool firstPlayerAdvantage = false, bool shouldParallel = true, bool showVerboseScore = true, bool showCompactScore = false, bool showDistribution = false, bool createHtmlReport = true, int numberOfGames = 1000, int logGameCount = 100, bool debugLogs = false, CreateGameLog createGameLog = null) { PlayerAction player1 = strategyLoader.GetPlayerAction(player1OrString); PlayerAction player2 = strategyLoader.GetPlayerAction(player2OrString); var strategyComparison = new StrategyComparison(player1, player2, gameConfig, firstPlayerAdvantage, numberOfGames); var results = strategyComparison.ComparePlayers( gameIndex => gameIndex < logGameCount ? GetGameLogWriterForIteration(player1, player2, gameIndex) : null, gameIndex => debugLogs && gameIndex < logGameCount ? GetDebugLogWriterForIteration(player1, player2, gameIndex) : null, shouldParallel: shouldParallel, gatherStats: createHtmlReport, createGameLog: createGameLog); if (showVerboseScore) { results.WriteVerboseScore(System.Console.Out); } if (showCompactScore) { results.WriteCompactScore(System.Console.Out); } if (showDistribution) { System.Console.WriteLine(""); System.Console.WriteLine("Player 1 Score Delta distribution"); System.Console.WriteLine("================================="); results.pointSpreadHistogramData.WriteBuckets(System.Console.Out); } if (createHtmlReport) { System.Threading.Interlocked.Increment(ref outstandingTasks); // write out HTML report summary var thread = new System.Threading.Thread(delegate() { var generator = new HtmlReportGenerator(results); generator.CreateHtmlReport(GetOuputFilename(player1.PlayerName + " VS " + player2.PlayerName + ".html")); System.Threading.Interlocked.Decrement(ref outstandingTasks); }); thread.Start(); } return(results.WinDifference); }