public void FirstRatingDerivative(int rnd) { //In this method we will use LINQ to make the query, just to practice using LINQ Rater Europa = new Rater(); float[] oppRatings = new float[rnd]; float[] theResults = new float[rnd]; int[] oppSeeds = new int[rnd]; foreach (Player p in AllPlayers) { for (int i = 0; i < rnd; i++) { oppSeeds[i] = p.getOpponent(i); theResults[i] = p.getResult(i); //we need to adjust for handi here! if we are white! //The rating needs to be increased by the number of handi we give. // if we are black (da da da) var linkquery = from matchPlayer in AllPlayers where matchPlayer.Seed == oppSeeds[i] select new { linkRating = matchPlayer.Rating }; // select new { linkRating = matchPlayer.getERating() }; //Maybe fairer in top group? foreach (var lq in linkquery) { oppRatings[i] = lq.linkRating; } if (p.getAdjHandi(i) != 0) oppRatings[i] += 100 * p.getAdjHandi(i); } p.firstRating = Europa.ObtainNewRating(oppRatings, p.Rating, theResults); // p.firstRating = Europa.ObtainNewRating(oppRatings, p.getERating(), theResults); } }
public void SecondRatingDerivative(int rnd) { Rater Europa = new Rater(); float[] oppRatings = new float[rnd]; float[] theResults = new float[rnd]; int[] oppSeeds = new int[rnd]; foreach (Player p in AllPlayers) { for (int i = 0; i < rnd; i++) { oppSeeds[i] = p.getOpponent(i); theResults[i] = p.getResult(i); var linkquery = from matchPlayer in AllPlayers where matchPlayer.Seed == oppSeeds[i] select new { linkRating = matchPlayer.firstRating }; foreach (var lq in linkquery) oppRatings[i] = lq.linkRating; if (p.getAdjHandi(i) != 0) oppRatings[i] += 100 * p.getAdjHandi(i); } p.secondRating = (int) Europa.ObtainNewRating(oppRatings, p.firstRating, theResults); } }