Skip to content

Commit

Permalink
use average instead of median
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHicks committed Oct 12, 2020
1 parent a52ebb8 commit 229618b
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/League.elm
Expand Up @@ -93,18 +93,15 @@ getPlayer name (League league) =
addPlayer : Player -> League -> League
addPlayer player (League league) =
let
ratings =
Dict.values league.players
|> List.map .rating
|> List.sort

medianishRating =
ratings
|> List.drop (List.length ratings // 2)
|> List.head
|> Maybe.withDefault Elo.initialRating
initialRating =
case Dict.values league.players |> List.map .rating of
[] ->
Elo.initialRating

nonEmpty ->
List.sum nonEmpty // List.length nonEmpty
in
League { league | players = Dict.insert player.name (Player.setRating medianishRating player) league.players }
League { league | players = Dict.insert player.name (Player.setRating initialRating player) league.players }


{-| -}
Expand Down

0 comments on commit 229618b

Please sign in to comment.