Beispiel #1
0
        public void Analyse()
        {
            var initialRatings = new List <PlayerRating>();

            foreach (var playerInformation in _PlayerData.Values)
            {
                var rating = new PlayerRating(playerInformation.Identity, InitialRating);
                initialRatings.Add(rating);
            }
            RatingEvaluation bestRatings = EvaluateRatings(initialRatings.ToArray());

            for (int i = 0; i < Iterations; i++)
            {
                var mutatedRatings          = GetMutatedRatings(bestRatings.Ratings);
                var mutatedRatingEvaluation = EvaluateRatings(mutatedRatings);
                if (mutatedRatingEvaluation.Error < bestRatings.Error)
                {
                    bestRatings = mutatedRatingEvaluation;
                }
            }
            Console.WriteLine("Error: {0}", bestRatings.Error);
            var ratings = bestRatings.Ratings.OrderByDescending(x => x.Rating);

            foreach (var rating in ratings)
            {
                var    playerInformation = _PlayerData[rating.Identity.SteamId];
                double?killDeathRatio    = null;
                if (playerInformation.DeathCount > 0)
                {
                    killDeathRatio = (double)playerInformation.KillCount / playerInformation.DeathCount;
                }
                Console.WriteLine("{0} ({1}): KDR {2:0.00}, rating {3:0.00}", rating.Identity.Name, rating.Identity.SteamId, killDeathRatio, rating.Rating);
            }
            PrintEncounterStatistics(ratings);
        }
Beispiel #2
0
        PlayerRating[] GetMutatedRatings(PlayerRating[] ratings)
        {
            int    index        = _Random.Next(_PlayerData.Count);
            var    playerRating = ratings[index];
            double newRating    = playerRating.Rating + (_Random.Next(2) == 1 ? 1 : -1) * _MutationSpeed;

            newRating = Math.Max(newRating, MinimumRating);
            var newPlayerRating = new PlayerRating(playerRating.Identity, newRating);

            _MutationSpeed = Math.Max(_MutationSpeed - MutationSpeedAdjustment, MinimumMutationSpeed);
            var newRatings = ratings.ToArray();

            newRatings[index] = newPlayerRating;
            return(newRatings);
        }