Example #1
0
        /// <summary>
        /// Create a new set of teams
        /// </summary>
        /// <param name="teamCount">The number of teams to generate</param>
        public async Task CreateNewRound(int teamCount, CancellationToken cancel)
        {
            var teams = new List <Team>();

            if (Settings.Algorithm2)
            {
                //var algo = new Algorithm2() {
                var algo = new Algorithm3()
                {
                    LoggingOn           = Settings.LoggingOn,
                    EvenRoundsGroupBest = Settings.EvenRoundsGroupBest,
                    LoggingPath         = _storage.LoggingPath,
                    Rounds = Rounds.ToList()
                };

                teams = algo.Generate(PlayerProvider, teamCount);
            }
            else
            {
                var numTeamGens = Settings.NumberOfGenerations;

                var teamCreator    = new RoundCreator();
                var winnersPenalty = new TooManyWinnersPenalty(PlayerProvider);
                var penalties      = new IPenalty[] { PlayerPairings, winnersPenalty };

                teams = await teamCreator.CreateApproximatelyOptimalTeams(penalties, PlayerProvider, numTeamGens, teamCount, cancel);
            }

            var filename = _storage.GetNextHatRoundPath();

            var round = new HatRound(teams, filename);

            round.SaveToFile();

            AddRound(round);
        }