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); } }
private IEnumerable <TournamentRound> RounRobinBuildAllPairings(IEnumerable <TournamentTeam> teams, IPairingsGenerator rrpg) { List <TournamentRound> rounds = new List <TournamentRound>(); while (true) { rrpg.LoadState(teams, rounds); TournamentRound newRound = rrpg.CreateNextRound(null); if (newRound != null) { rounds.Add(newRound); } else { break; } } foreach (TournamentRound round in rounds) { yield return(round); } yield break; }
private IEnumerable<TournamentRound> RounRobinBuildAllPairings(IEnumerable<TournamentTeam> teams, IPairingsGenerator rrpg) { List<TournamentRound> rounds = new List<TournamentRound>(); while (true) { rrpg.LoadState(teams, rounds); TournamentRound newRound = rrpg.CreateNextRound(null); if (newRound != null) { rounds.Add(newRound); } else { break; } } foreach (TournamentRound round in rounds) { yield return round; } yield break; }
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); } }