当前位置: 首页>>代码示例>>C#>>正文


C# Match.Run方法代码示例

本文整理汇总了C#中Match.Run方法的典型用法代码示例。如果您正苦于以下问题:C# Match.Run方法的具体用法?C# Match.Run怎么用?C# Match.Run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Match的用法示例。


在下文中一共展示了Match.Run方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateResult

        public override CompetitorRanks GenerateResult(MatchStrategy matchStrategy, List<Competitor> competitors)
        {
            List<Match> matches = new List<Match>();

            if (competitors.Count % 2 != 0)
                throw new ArgumentException("Collection count must be even.", "competitors");

            // generate the results for the competitors
            // note that the competitors are paired in this round by the order they're in in the List object
            // pairing first with last, second with second-to-last, etc.
            for (int index = 0; index < competitors.Count / 2; index++)
            {
                int mirrorIndex = competitors.Count - (index + 1);

                Competitor competitorA = competitors[index];
                Competitor competitorB = competitors[mirrorIndex];

                Match match = new Match(matchStrategy, WinsToClinchMatch);
                match.Run(competitorA, competitorB);
                matches.Add(match);
            }

            Matches = matches;

            CompetitorPoints tournamentRoundPoints = AccumulateMatchPoints(matches);
            return tournamentRoundPoints.GetCompetitorRanks();
        }
开发者ID:bejubi,项目名称:TournamentFormatResearch,代码行数:27,代码来源:KoTRS.cs

示例2: GenerateSingleRoundResult

        // TODO: change the signature to accept a number of additional rounds, rather than the fraction
        private List<Match> GenerateSingleRoundResult(MatchStrategies.MatchStrategy matchStrategy, List<Competitor> competitors, double fractionOfPartialRound)
        {
            if (fractionOfPartialRound > 1.0 || fractionOfPartialRound < 0 || fractionOfPartialRound == 0)
                throw new ArgumentException("Must be greater than 0.0 and less than or equal to 1.0.", "fractionOfPartialRound");

            List<Match> matches = new List<Match>();

            // The standard algorithm is to write competitor numbers in a 2-row grid with 
            // numbers going clockwise. Then, fixing one of the team numbers in place, rotate the 
            // others around it until done. Match-ups are top and bottom in the column.

            // fill the indexes the first time, including anything to make an even number of indexes
            List<int> competitorIndexes = new List<int>();
            for (int i = 0; i < competitors.Count + (competitors.Count % 2); i++)
            {
                competitorIndexes.Add(i);
            }

            int numberOfRounds = Convert.ToInt32(Math.Round((competitorIndexes.Count - 1) * fractionOfPartialRound));

            // for each round, advance the indexes in the list, except for the last one
            for (int i = 0; i < numberOfRounds; i++)
            {
                // run the matches for the round
                for (int j = 0; j < competitorIndexes.Count / 2; j++)
                {
                    // if the number of competitors is odd, give the first competitor a bye
                    if ((competitors.Count % 2) == 1 && j == 0)
                        continue;

                    // choose the first and last, second and second-to-last, etc.
                    Competitor competitorA = competitors[competitorIndexes[j]];
                    Competitor competitorB = competitors[competitorIndexes[competitorIndexes.Count - j - 1]];

                    Match match = new Match(matchStrategy, WinsToClinchMatch);
                    match.Run(competitorA, competitorB);
                    matches.Add(match);
                }

                // increment the indexes for the next round
                for (int j = 0; j < competitorIndexes.Count - 1; j++)
                {
                    competitorIndexes[j] = (competitorIndexes[j] + 1) % (competitorIndexes.Count - 1);
                }
            }

            return matches;
        }
开发者ID:bejubi,项目名称:TournamentFormatResearch,代码行数:49,代码来源:RrTRS.cs


注:本文中的Match.Run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。