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); }
private double CalculateTeamAverageElo(IEnumerable <Guardian> guardians) { double elo = 0; foreach (var guardian in guardians) { elo += _guardianEloRepository.GetGuardianElo(guardian.Id).Result.NewElo; } return(elo / guardians.Count()); }
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)); }