Last active
June 18, 2022 20:24
-
-
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/)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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