Make the scale/unscale functions publically callable.
Move ranking opponent data inside the struct of the player.

This will greatly simplify calculation code. The mapping becomes straightforward once it has been built and can run very quickly on each player. The remaining task is to populate the structure from the database.
Introduce a number of fixes to the algorithm.