# 0xMonaco "Elo → Score" Logic
Teams who compete in the 0xMonaco challenge will be scored competitively using the [Elo rating system](https://en.wikipedia.org/wiki/Elo_rating_system). Because the game involves more than two players, we'll use Tom Kerrigan's [Simple Multiplayer Elo](http://www.tckerrigan.com/Misc/Multiplayer_Elo/) algorithim to actually assign elos after each multiplayer race.
Once races conclude, we'll begin by constructing a list of all teams who were within 191 elo of the team with the highest elo. A max distance of 191 was chosen as it roughly translates to the underdog having a 75% chance of winning vs the higher elo player.
Each team will then be assigned an "adjusted elo" which will equal the distance of the team's elo from the lowest elo in the set, squared. Then each team given will be alloated a percentage of the challenge's prize pool according to what percentage their adjusted elo comprimises of the sum of adjusted elos in the set.
## Formalization
Let there be a set of elos $\{x_1,x_2,\dots,x_n\}$ such that:
- $x_1$ represents the highest elo of the set
- $x_n$ represents the lowest elo of the set
- $x_1 - x_n \leq 191.$
For a team $t$ in the set (teams not in the set will not be allocated any points), their final point score, $p_t$, can be computed like so:
$$ p_t = \left\lfloor P \frac{(x_t - x_n)^2}{\sum_{k=1}^{n} (x_k - x_n)^2}\right\rfloor $$
Where $P$ is the total number of points allocated for the challenge's prize pool.
## Implementation
```python
import math
points_to_distribute = 1000 # The amount of points to distribute amongst top players.
elos = [1710, 1690, 1689, 1650, 1600, 1550, 1500, 1450, 1400, 1350, 1300, 1250, 1200, 1150, 1100, 1050, 1000, 950, 900, 850, 800, 750, 700, 650, 600, 550, 500, 450, 400, 350, 300, 250, 200, 150, 100, 50, 0]
highest_elo = max(elos) # The team with the highest elo.
filtered_elos = [] # An array for all teams within 191 elo of highest_elo.
# Remove all teams who were not within 191 elo of the highest elo team.
for elo in elos:
if highest_elo - elo <= 191:
filtered_elos.append(elo)
# Find the lowest performing team and use their elo as the baseline.
baseline = min(filtered_elos)
# Sum up all of the adjusted elos.
sum = 0
for elo in filtered_elos:
sum += (elo - baseline) ** 2
# Determine each team's percentage of the prize pool
# using their share of the sum of adjusted elos.
for elo in filtered_elos:
print(math.floor(points_to_distribute * ((elo - baseline) ** 2 / sum)))
```
```javascript
λ python3 elo.py
332
254
250
129
32
0
```
## Acknowledgments
Credit for this algorithm goes to [Robert Chen](https://twitter.com/NotDeGhost) of OtterSec.

or

By clicking below, you agree to our terms of service.

Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet

Wallet
(
)

Connect another wallet
New to HackMD? Sign up