mirror of
https://github.com/avitex/elixir-glicko
synced 2024-11-22 03:09:57 +00:00
Add e to results
This commit is contained in:
parent
7d46daf078
commit
66133e48d1
@ -26,12 +26,14 @@ defmodule Glicko do
|
|||||||
|
|
||||||
defp do_new_rating(player = %Player{version: :v2}, results, sys_constant) do
|
defp do_new_rating(player = %Player{version: :v2}, results, sys_constant) do
|
||||||
results = Enum.map(results, fn result ->
|
results = Enum.map(results, fn result ->
|
||||||
opponent = Player.to_v2(result.opponent)
|
result =
|
||||||
%{
|
Map.new
|
||||||
score: result.score,
|
|> Map.put(:opponent, Player.to_v2(result.opponent))
|
||||||
opponent: opponent,
|
|> Map.put(:score, result.score)
|
||||||
opponent_rating_deviation_g: calc_g(opponent.rating_deviation),
|
|
||||||
}
|
result = Map.put(result, :opponent_rating_deviation_g, calc_g(result.opponent.rating_deviation))
|
||||||
|
result = Map.put(result, :e, calc_e(player, result))
|
||||||
|
result
|
||||||
end)
|
end)
|
||||||
|
|
||||||
ctx =
|
ctx =
|
||||||
@ -74,11 +76,10 @@ defmodule Glicko do
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Calculation of the estimated variance of the player's rating based on game outcomes
|
# Calculation of the estimated variance of the player's rating based on game outcomes
|
||||||
defp calc_variance_estimate(%{player: player, results: results}) do
|
defp calc_variance_estimate(%{results: results}) do
|
||||||
results
|
results
|
||||||
|> Enum.reduce(0.0, fn result, acc ->
|
|> Enum.reduce(0.0, fn result, acc ->
|
||||||
tmp_e = calc_e(player, result)
|
acc + :math.pow(result.opponent_rating_deviation_g, 2) * result.e * (1 - result.e)
|
||||||
acc + :math.pow(result.opponent_rating_deviation_g, 2) * tmp_e * (1 - tmp_e)
|
|
||||||
end)
|
end)
|
||||||
|> :math.pow(-1)
|
|> :math.pow(-1)
|
||||||
end
|
end
|
||||||
@ -102,9 +103,9 @@ defmodule Glicko do
|
|||||||
:math.exp(a / 2)
|
:math.exp(a / 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp calc_results_effect(%{player: player, results: results}) do
|
defp calc_results_effect(%{results: results}) do
|
||||||
Enum.reduce(results, 0.0, fn result, acc ->
|
Enum.reduce(results, 0.0, fn result, acc ->
|
||||||
acc + result.opponent_rating_deviation_g * (result.score - calc_e(player, result))
|
acc + result.opponent_rating_deviation_g * (result.score - result.e)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user