コード例 #1
0
        public async Task <IEnumerable <MatchMadeTeam> > MatchTeams(IEnumerable <string> guardianIds, int teamSize)
        {
            var guardians = new List <GuardianSnapshot>();

            foreach (var id in guardianIds)
            {
                var guardian = await _guardianRepository.GetGuardian(id);

                var guardianElo = await _guardianEloRepository.GetGuardianElo(id);

                var guardianEff = _guardianEfficiencyRepository.GetGuardianEfficiency(id);

                var snapshot = new GuardianSnapshot()
                {
                    Guardian           = guardian,
                    GuardianEfficiency = guardianEff.NewEfficiency,
                    GuardianElo        = guardianElo.NewElo
                };

                guardians.Add(snapshot);
            }

            var shuffledGuardians = _matchMakingRepository.ShuffleGuardiansList(guardians);
            var teams             = _matchMakingRepository.RandomizeTeams(shuffledGuardians, teamSize);

            teams = _matchMakingRepository.Anneal(teams);

            return(teams);
        }
コード例 #2
0
        public async Task <IEnumerable <GuardianSnapshot> > GetGuardians()
        {
            var guardians = await _guardianRepository.GetAllGuardians();

            var guardianSnapshots = new List <GuardianSnapshot>();

            foreach (var guardian in guardians)
            {
                var guardianElo = await _guardianEloRepository.GetGuardianElo(guardian.Id);

                var guardianEff      = _guardianEfficiencyRepository.GetGuardianEfficiency(guardian.Id);
                var guardianSnapshot = new GuardianSnapshot()
                {
                    Guardian           = guardian,
                    GuardianElo        = guardianElo?.NewElo ?? 1200,
                    GuardianEfficiency = guardianEff?.NewEfficiency ?? 0.0,
                };

                guardianSnapshots.Add(guardianSnapshot);
            }

            return(guardianSnapshots.OrderByDescending(g => g.GuardianElo));
        }