1
0
mirror of https://github.com/avitex/elixir-glicko synced 2024-12-22 08:29:57 +00:00

Add tests and example for win_probability

This commit is contained in:
avitex 2017-11-29 13:10:02 +11:00
parent 82bd9e54ba
commit 71e06435bf
2 changed files with 19 additions and 0 deletions

View File

@ -21,6 +21,13 @@ defmodule Glicko do
iex> Glicko.new_rating(player, [], [system_constant: 0.5])
{1.5e3, 200.27141669877065}
Calculate the probability of a player winning against an opponent.
iex> player = Player.new_v1
iex> opponent = Player.new_v1
iex> Glicko.win_probability(player, opponent)
0.5
"""
alias __MODULE__.{

View File

@ -35,4 +35,16 @@ defmodule GlickoTest do
assert_in_delta Player.rating_deviation(player), @valid_player_rating_deviation_after_no_results, 1.0e-4
end
test "win probability with same ratings" do
assert Glicko.win_probability(Player.new_v1, Player.new_v1) == 0.5
end
test "win probability with better opponent" do
assert Glicko.win_probability(Player.new_v1([rating: 1500]), Player.new_v1([rating: 1600])) < 0.5
end
test "win probability with better player" do
assert Glicko.win_probability(Player.new_v1([rating: 1600]), Player.new_v1([rating: 1500])) > 0.5
end
end