**Not a member of Pastebin yet?**

**, it unlocks many cool features!**

__Sign Up__- -- | Projected result of valuation A vs valuation B, with 1 = sure win
- -- for A, 0 = sure win for B.
- --
- -- This is the core formula of Elo.
- projected :: Float -> Float -> Float
- projected a b = 1 / (1 + exp ( log 10 / e * (b-a) ) )
- where e = 400
- -- | Points to grant the first player for a given result of a 1vs1
- points1vs1 :: Float -> Float -> Float -> Float
- points1vs1 a b d = d - projected a b
- -- | 1vs1 result to assume for a player finishing in i-th place vs a
- -- player finishing in j-th place.
- --
- -- It's important that "result i j = 1 - result j i" holds!
- result :: Int -> Int -> Float
- result i j
- | i < j = 1
- | otherwise = 0
- -- | Weight to put on a 1vs1 pairing. We assume that players finishing
- -- fast have played less long, and therefore reduce the weight on
- -- their results.
- --
- -- It's important that "weight i j = weight j i"
- weight :: Int -> Int -> Float
- weight i j = 20 / fromIntegral (max i j)
- -- | Bonus for players close to seed level. Make it so players can never
- -- fall under 0 points.
- seedBonus :: Float -> Float -> Float
- seedBonus a v
- | v >= 0 = v
- | a < f = v * a / f
- | otherwise = v
- where f = 300
- -- | NvsN evaluation. Assumes valuations are sorted by finishing placement.
- pointsFree :: [Float] -> [Float]
- pointsFree rs =
- [ seedBonus a $ sum [ weight i j * points1vs1 a b (result i j)
- | (j, b) <- rps, i /= j]
- | (i, a) <- rps]
- where rps = zip [1..] rs

RAW Paste Data