public double ScorePenaltyForGender(List <Team> teams, Gender gender) { var maxScore = _players.MaxGameScore(gender); var winningPerTeam = teams.Select(t => t.Players.Count(p => p.GameScore == maxScore)).ToList(); var totalWinning = winningPerTeam.Sum(); var expectedWinnersPerTeam = totalWinning / (double)teams.Count; // Sum the square root of the deviations from the expected number of winners // Square root shrinks the dynamic range, so as to make the better options // more standout after normalisation var result = winningPerTeam.Sum(s => Math.Sqrt(Math.Abs(s - expectedWinnersPerTeam))); return(result); }
public static IEnumerable <Player> WinningPlayers(this IPlayerProvider playerProvider, Gender gender) { return(playerProvider.AllPlayers.Where(p => p.Gender == gender && p.GameScore == playerProvider.MaxGameScore(gender))); }