public RoundResult RunRound(BaseBot player1, BaseBot player2, RoundResult previousResult) { var p1Decision = player1.GetDecision(previousResult.ToPlayerSpecific(player1)); var p2Decision = player2.GetDecision(previousResult.ToPlayerSpecific(player2)); BaseBot winner = null; // confirm each has a valid choice bool player1Invalid = IsInvalidDecision(p1Decision, player1); bool player2Invalid = IsInvalidDecision(p2Decision, player2); if (player1Invalid || player2Invalid) { if (player1Invalid && player2Invalid) { // tie - also, what did you do?!?! } else if (player1Invalid) { winner = player2; } else { winner = player1; } } else { if (p1Decision == p2Decision) { // tie } else if (p1Decision.IsWinnerAgainst(ref p2Decision)) { winner = player1; } else { winner = player2; } } var roundResult = new RoundResult { MatchResult = previousResult.MatchResult, Winner = winner?.Competitor, Player1 = player1.Competitor, Player2 = player2.Competitor, Player1Played = p1Decision, Player2Played = p2Decision, }; ApplyDynamiteUsageToBots(player1, p1Decision, player2, p2Decision); return(roundResult); }
internal Decision GetDecision(BaseBot player, RoundResult previousResult, IMetrics metrics) { var stopwatch = System.Diagnostics.Stopwatch.StartNew(); var d = player.GetDecision(previousResult.ToPlayerSpecific(player)); stopwatch.Stop(); var metric = new Dictionary <string, double> { { "DecisionTime", stopwatch.Elapsed.TotalMilliseconds } }; var properties = new Dictionary <string, string> { { "Bot", player.Name } }; metrics.TrackEventDuration("BotDesicionTime", properties, metric); return(d); }