public string GetResponse(WebService service) { StrategyComparisonResults comparisonResults = service.GetResultsFor(this); var HtmlReportGenerator = new HtmlReportGenerator(comparisonResults); return(HtmlReportGenerator.CreateHtmlReport()); }
internal StrategyComparisonResults GetResultsFor(ComparisonDescription descr) { StrategyComparisonResults result = null; if (!this.resultsCache.TryGetValue(descr, out result)) { GameConfigBuilder builder = new GameConfigBuilder(); PlayerAction playerAction1 = descr.Player1Action; PlayerAction playerAction2 = descr.Player2Action; if (playerAction1 != null && playerAction2 != null) { System.Console.WriteLine("Playing {0} vs {1}", playerAction1.PlayerName, playerAction2.PlayerName); PlayerAction.SetKingdomCards(builder, new PlayerAction[] { playerAction1, playerAction2 }); var gameConfig = builder.ToGameConfig(); var strategyComparison = new StrategyComparison(playerAction1, playerAction2, gameConfig, rotateWhoStartsFirst: true, numberOfGames: 1000); result = strategyComparison.ComparePlayers( gameIndex => null, gameIndex => null, shouldParallel: true, gatherStats: true); this.resultsCache.Add(descr, result); } else { this.resultsCache.Add(descr, null); } } return(result); }
public object GetResponse(WebService service) { StrategyComparisonResults comparisonResults = service.GetResultsFor(this); if (comparisonResults == null) { return(null); } var data = new List <object>(); data.Add(new string[] { "Player", "Percent" }); for (int index = 0; index < comparisonResults.winnerCount.Length; ++index) { data.Add(new object[] { comparisonResults.comparison.playerActions[index].name, comparisonResults.PlayerWinPercent(index) }); } if (comparisonResults.tieCount > 0) { data.Add(new object[] { "Tie", comparisonResults.TiePercent }); } var options = new Dictionary <string, object>(); options.Add("title", "Game Breakdown"); var result = new Dictionary <string, object>(); result.Add("data", data); result.Add("options", options); result.Add("type", "pie"); return(result); }
public object GetResponse(WebService service) { StrategyComparisonResults comparisonResults = service.GetResultsFor(this); return(GetLineGraphData(comparisonResults, "Probability player is ahead in points at end of round ", comparisonResults.statGatherer.oddsOfBeingAheadOnRoundEnd)); }
public object GetResponse(WebService service) { StrategyComparisonResults comparisonResults = service.GetResultsFor(this); return(GetLineGraphData(comparisonResults, "Coin To Spend Per Turn", comparisonResults.statGatherer.coinToSpend)); }
public object GetResponse(WebService service) { StrategyComparisonResults comparisonResults = service.GetResultsFor(this); return(GetLineGraphData(comparisonResults, "Victory Point Total Per Turn", comparisonResults.statGatherer.victoryPointTotal)); }
public object GetResponse(WebService service) { StrategyComparisonResults comparisonResults = service.GetResultsFor(this); if (comparisonResults == null) { return(null); } string result = comparisonResults.comparison.GetHumanReadableGameLog(gameNumber - 1); return(result); }
public object GetResponse(WebService service) { StrategyComparisonResults comparisonResults = service.GetResultsFor(this); var options = GoogleChartsHelper.GetLineGraphOptions( "Point Spread", "Score", "Percentage", comparisonResults.pointSpreadHistogramData.GetXAxis(), comparisonResults.pointSpreadHistogramData.GetYAxis()); return(options); }
public void AddResults(StrategyComparisonResults results, Func <string, string> GetOutputFilename) { System.Threading.Interlocked.Increment(ref outstandingTasks); // write out HTML report summary var thread = new System.Threading.Thread(delegate() { var generator = new HtmlReportGenerator(results); CreateHtmlReport(generator, GetOutputFilename(results.comparison.playerActions[0].PlayerName + " VS " + results.comparison.playerActions[1].PlayerName + ".html")); System.Threading.Interlocked.Decrement(ref outstandingTasks); }); thread.Start(); }
public object GetResponse(WebService service) { StrategyComparisonResults comparisonResults = service.GetResultsFor(this); int maxTurn = comparisonResults.gameEndOnTurnHistogramData.GetXAxisValueCoveringUpTo(97); var options = GoogleChartsHelper.GetLineGraphOptions( "Probability of Game Ending on Turn", "Score", "Percentage", comparisonResults.gameEndOnTurnHistogramData.GetXAxis(maxTurn), comparisonResults.gameEndOnTurnHistogramData.GetYAxis(maxTurn)); return(options); }
protected object GetLineGraphData( StrategyComparisonResults comparisonResults, string title, ForwardAndReversePerTurnPlayerCounters counters) { if (!counters.forwardTotal.HasNonZeroData) { return(null); } int maxTurn = comparisonResults.gameEndOnTurnHistogramData.GetXAxisValueCoveringUpTo(97); var options = GoogleChartsHelper.GetLineGraphOptions( "title", comparisonResults.comparison.playerActions[0].PlayerName, comparisonResults.comparison.playerActions[1].PlayerName, counters, comparisonResults.statGatherer.turnCounters, maxTurn); return(options); }
public static string GetHtmlReport(StrategyComparisonResults comparisonResults) { var htmlGenerator = new HtmlReportGenerator(comparisonResults); return(htmlGenerator.CreateHtmlReport()); }
public HtmlReportGenerator(StrategyComparisonResults comparisonResults) { this.comparisonResults = comparisonResults; }