本文整理汇总了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();
}
示例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;
}