mirror of
https://github.com/avitex/elixir-glicko
synced 2024-11-24 20:19:57 +00:00
Add tests and example for win_probability
This commit is contained in:
parent
82bd9e54ba
commit
71e06435bf
@ -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__.{
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user