Ejemplo n.º 1
0
        public static IEnumerable <IDictionary <Player, Rating> > ConvertToMoserware(List <Participant> redPlayers, List <Participant> bluePlayers)
        {
            var redTeam = new Moserware.Skills.Team();

            foreach (Participant participant in redPlayers)
            {
                redTeam.AddPlayer(
                    new Player(participant.ParticipantId),
                    new Rating(
                        participant.Mean,
                        participant.StandardDeviation));
            }

            var blueTeam = new Moserware.Skills.Team();

            foreach (Participant participant in bluePlayers)
            {
                blueTeam.AddPlayer(
                    new Player(participant.ParticipantId),
                    new Rating(
                        participant.Mean,
                        participant.StandardDeviation));
            }

            return(Moserware.Skills.Teams.Concat(blueTeam, redTeam));
        }
        public IEnumerable <PlayerRankingEntry> DetermineRanking(Records data)
        {
            foreach (var player in data.GetPlayers())
            {
                _players[player] = new Moserware.Skills.Player(player);
                _ratings[player] = GameInfo.DefaultGameInfo.DefaultRating;
            }

            foreach (var game in data.Games)
            {
                var team1 = new Moserware.Skills.Team()
                            .AddPlayer(_players[game.Team1Player1], _ratings[game.Team1Player1])
                            .AddPlayer(_players[game.Team1Player2], _ratings[game.Team1Player2]);

                var team2 = new Moserware.Skills.Team()
                            .AddPlayer(_players[game.Team2Player1], _ratings[game.Team2Player1])
                            .AddPlayer(_players[game.Team2Player2], _ratings[game.Team2Player2]);

                var teams             = Moserware.Skills.Teams.Concat(team1, team2);
                var newRatingsWinLose = _calculator.CalculateNewRatings(_gameInfo, teams, game.ScoreTeam1 > game.ScoreTeam2 ? 1 : 2, game.ScoreTeam2 > game.ScoreTeam1 ? 1 : 2);

                foreach (var newRating in newRatingsWinLose)
                {
                    _ratings[(Player)newRating.Key.Id] = newRating.Value;
                }
            }

            foreach (var rating in _ratings)
            {
                yield return(new PlayerRankingEntry()
                {
                    Player = rating.Key,
                    Score = rating.Value.Mean
                });
            }
        }
Ejemplo n.º 3
0
        public Dictionary<string, HLTVTeam> GenerateTrueSkill(DateTime start, DateTime end)
        {
            List<HLTVMatch> skill_matches = new List<HLTVMatch>(match_list);
            skill_matches.RemoveAll(o => o.date < start);
            skill_matches.RemoveAll(o => o.date > end);

            Console.WriteLine("Generating rankings between " + skill_matches[0].date.ToShortDateString() + " and " + skill_matches[skill_matches.Count - 1].date.ToShortDateString());

            foreach(HLTVTeam t in teams.Values)
            {
                t.rating = GameInfo.DefaultGameInfo.DefaultRating;
                t.rating = GameInfo.DefaultGameInfo.DefaultRating;
                t.reset_dates.Clear();
            }

            AddResetDates();

            foreach (HLTVMatch m in skill_matches)
            {
                if (reset_team_ranking(m.team_a, m.date))
                {
                    Console.WriteLine("Resetting " + m.team_a.name + " on " + m.date.ToShortDateString());
                    m.team_a.rating = GameInfo.DefaultGameInfo.DefaultRating;
                }

                if (reset_team_ranking(m.team_b, m.date))
                {
                    Console.WriteLine("Resetting " + m.team_b.name + " on " + m.date.ToShortDateString());
                    m.team_b.rating = GameInfo.DefaultGameInfo.DefaultRating;
                }

                var player1 = new Player(m.team_a);
                var player2 = new Player(m.team_b);
                var gameInfo = GameInfo.DefaultGameInfo;
                var team1 = new Moserware.Skills.Team(player1, m.team_a.rating);
                var team2 = new Moserware.Skills.Team(player2, m.team_b.rating);
                var ts_teams = Moserware.Skills.Teams.Concat(team1, team2);
                var newRatings = TrueSkillCalculator.CalculateNewRatings(gameInfo, ts_teams,
                    (m.a_rounds > m.b_rounds) ? 1 : 2,
                    (m.a_rounds > m.b_rounds) ? 2 : 1);

                m.team_a.rating = newRatings[player1];
                m.team_b.rating = newRatings[player2];

                teams[m.team_a.name].rating = newRatings[player1];
                teams[m.team_b.name].rating = newRatings[player2];
            }

            return teams;
        }