Skip to content

Commit

Permalink
describe expectations of score differentials
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHicks committed Sep 11, 2020
1 parent 158f2f2 commit 29612aa
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions tests/EloTest.elm
@@ -1,6 +1,6 @@
module EloTest exposing (..)

import Elo
import Elo exposing (..)
import Expect exposing (FloatingPointTolerance(..))
import Fuzz exposing (Fuzzer)
import Test exposing (..)
Expand Down Expand Up @@ -32,10 +32,32 @@ oddsTest =
describe "odds"
[ fuzz ratingFuzzer "given equal ratings, the outcome is 50/50" <|
\rating ->
Elo.odds rating rating
odds rating rating
|> Expect.within (Relative 0.001) 0.5
, fuzz inequalRatingsFuzzer "given inequal ratings, the outcome favors the higher of the two ratings" <|
\( a, b ) ->
Elo.odds (max a b) (min a b)
odds (max a b) (min a b)
|> Expect.greaterThan 0.5
]


newRating : Test
newRating =
describe "newRating"
[ fuzz ratingFuzzer "a player gains more points by winning against a heavy favorite than a relative equal" <|
\player ->
let
equal =
player + 100

favorite =
player + 1000

( newAgainstEqual, _ ) =
Elo.newRating Elo.sensitiveKFactor player WonAgainst equal

( newAgainstFavorite, _ ) =
Elo.newRating Elo.sensitiveKFactor player WonAgainst favorite
in
newAgainstEqual |> Expect.lessThan newAgainstFavorite
]

0 comments on commit 29612aa

Please sign in to comment.