Esempio n. 1
0
 public void Render(IGraphics graphics, TournamentNameTable teamNames)
 {
     throw new NotImplementedException();
 }
Esempio n. 2
0
        public void SingleEliminationHandlesManyCompetitorsWell()
        {
            IPairingsGenerator pg = new EliminationTournament(1);

            for (int i = 30; i <= 40; i++)
            {
                List<TournamentTeam> teams = new List<TournamentTeam>(CreateTeams(i));
                List<TournamentRound> rounds = new List<TournamentRound>();

                Dictionary<long, string> teamNames = new Dictionary<long, string>();
                foreach (var team in teams)
                {
                    teamNames.Add(team.TeamId, "Team#" + team.TeamId);
                }

                TournamentNameTable nameTable = new TournamentNameTable(teamNames);

                try
                {
                    RunTournament(pg, teams, rounds, false, nameTable);

                    DisplayTournamentRounds(rounds);
                    DisplayTournamentRankings(pg.GenerateRankings());
                }
                catch (InvalidTournamentStateException)
                {
                    throw;
                }
            }
        }
Esempio n. 3
0
 public SizeF Measure(IGraphics graphics, TournamentNameTable teamNames)
 {
     throw new NotImplementedException();
 }
Esempio n. 4
0
        public void RunTournament(IPairingsGenerator pg, List<TournamentTeam> teams, List<TournamentRound> rounds, bool allowTies, TournamentNameTable nameTable)
        {
            ITournamentVisualizer viz = null;
            if (nameTable != null)
            {
                viz = pg as ITournamentVisualizer;
            }

            while (true)
            {
                pg.LoadState(teams, rounds);
                TournamentRound newRound = pg.CreateNextRound(null);

                if (viz != null)
                {
                    var gfx = new SystemGraphics();
                    var q2 = viz.Measure(gfx, nameTable);
                    viz.Render(gfx, nameTable);
                }

                if (newRound == null)
                {
                    pg.LoadState(teams, rounds);
                    newRound = pg.CreateNextRound(null);
                    break;
                }

                if (allowTies)
                {
                    foreach (var pairing in newRound.Pairings)
                    {
                        foreach (var teamScore in pairing.TeamScores)
                        {
                            teamScore.Score = new HighestPointsScore(r.Next(20));
                        }
                    }
                }
                else
                {
                    foreach (var pairing in newRound.Pairings)
                    {
                        List<double> scoresUsed = new List<double>();
                        foreach (var teamScore in pairing.TeamScores)
                        {
                            double score;
                            do
                            {
                                score = r.NextDouble();
                            } while (scoresUsed.Where(s => s == score).Any());

                            teamScore.Score = new HighestPointsScore(score);
                        }
                    }
                }

                rounds.Add(newRound);
            }
        }