Skip to content

Instantly share code, notes, and snippets.

@michaelenglo
Last active June 18, 2022 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelenglo/12858895d7a93bfd5dcd455d4344454e to your computer and use it in GitHub Desktop.
Save michaelenglo/12858895d7a93bfd5dcd455d4344454e to your computer and use it in GitHub Desktop.
Calculate FIFA Ultimate Team Squad Ratings (from https://fifauteam.com/fifa-21-squad-rating-guide/)
def calculate_ratings(players):
# Get the sum for all players ratings
player_ratings = map(lambda x: x.ratings, players)
sum_player_ratings = sum(player_ratings)
# Also get the average
average_player_ratings = sum_player_ratings / 11
# Calculate the correction factor (for each player, it's either positive delta or 0) and get the total.
correction_factor = sum(map(lambda x: max(0, x - average_player_ratings), player_ratings))
# Take the total sum of player ratings + correction factor, round it, divide it by 11, and round it again.
total = round(sum_player_ratings + correction_factor) # has to be rounded
squad_ratings = round(total / 11)
return squad_ratings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment