Пример #1
0
        /// <summary>
        /// Create all pairings and games for all groups
        /// </summary>
        private void CreateGroupPairings(IRandomGen random)
        {
            // Create groups
            var shuffledTeams = this.Teams.Shuffle(random);
            var teamIterator  = shuffledTeams.GetEnumerator();

            for (int i = 0; i < this.NumberOfTeams / Tournament.GroupSize; ++i)
            {
                var group = new TournamentGroup(this, i + 1);

                for (int j = 0; j < Tournament.GroupSize; ++j)
                {
                    teamIterator.MoveNext();
                    group.Teams.Add(teamIterator.Current);
                }

                this.Groups.Add(group);
            }

            // Create pairings so that each team plays against all others
            int order = 0;

            foreach (var group in this.Groups)
            {
                for (int i = 0; i < group.Teams.Count(); ++i)
                {
                    for (int j = i + 1; j < group.Teams.Count(); ++j)
                    {
                        var teamA = group.Teams.ElementAt(i);
                        var teamB = group.Teams.ElementAt(j);

                        var pairing = this.CreatePairing(order++, teamA, teamB, this.NumberOfGroupGames);

                        pairing.Group   = group;
                        pairing.GroupId = group.Id;

                        group.Pairings.Add(pairing);
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Create all pairings and games for all groups
        /// </summary>
        private void CreateGroupPairings()
        {
            // Create groups
            var shuffledTeams = this.Teams.Shuffle();
            var teamIterator = shuffledTeams.GetEnumerator();

            for (int i = 0; i < this.NumberOfTeams / Tournament.GroupSize; ++i)
            {
                var group = new TournamentGroup(this, i + 1);

                for(int j = 0; j < Tournament.GroupSize; ++j)
                {
                    teamIterator.MoveNext();
                    group.Teams.Add(teamIterator.Current);
                }

                this.Groups.Add(group);
            }

            // Create pairings so that each team plays against all others
            int order = 0;

            foreach (var group in this.Groups)
            {
                for(int i = 0; i < group.Teams.Count(); ++i)
                {
                    for(int j = i + 1; j < group.Teams.Count(); ++j)
                    {
                        var teamA = group.Teams.ElementAt(i);
                        var teamB = group.Teams.ElementAt(j);

                        var pairing = this.CreatePairing(order++, teamA, teamB, this.NumberOfGroupGames);

                        pairing.Group = group;
                        pairing.GroupId = group.Id;

                        group.Pairings.Add(pairing);
                    }
                }
            }
        }