Example #1
0
        private void Finish(Action <List <string>, TimeSpan> finishedCallback)
        {
            TimeSpan elapsed = DateTime.Now - mStartTime;

            List <string> results = new List <string>();

            lock (WinnerCounts)
            {
                results.Add($"Analyzed {TotalCalculations} possible outcomes in {elapsed}");
                results.Add($"{TieOutcomes / TotalCalculations * 100:0.00}% result in unbreakable tie ({TieOutcomes} outcomes)");
                for (int i = 0; i < ScenariosCalculated.Count; i++)
                {
                    results.Add($"Spent {ScenariosCalculated[i] / 1000} s on {ScenariosCalculated[i]} {i + 1}-winner scenarios ({ScenarioTimes[i] / ScenariosCalculated[i]} ms/calc)");
                }
                results.Add("Team,OutrightWinner,TieMember");
                foreach (int teamId in WinnerCounts.Keys)
                {
                    Team team = mLeague.FindTeam(teamId);
                    results.Add($"{team.Name},{WinnerCounts[teamId] / TotalCalculations * 100:0.00}%,{TieCounts[teamId] / (double)TieOutcomes * 100:0.00}%");
                }

                if (mTeam != null)
                {
                    results.Add(string.Empty);
                    results.Add($"{mTeam.Name} required game outcomes:");
                    foreach (int gameId in mCommonGamesForTargetDivisionWinner.Keys)
                    {
                        Game game     = mGames.FindMatchup(gameId);
                        int  winnerId = mCommonGamesForTargetDivisionWinner[gameId];
                        Team winner   = mLeague.FindTeam(winnerId);
                        int  loserId  = winnerId == game.HomeTeamId ? game.AwayTeamId : game.HomeTeamId;
                        Team loser    = mLeague.FindTeam(loserId);
                        results.Add($"{winner.Name} beats {loser.Name}");
                    }
                }
            }

            finishedCallback(results, elapsed);
        }