add decay when results are empty and retab file
This commit is contained in:
1 parent
5b64f13b89
commit
cbe79afd1f
2 files changed
+10
-8
No files matched your search
+7
-5
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env ruby
|
||||
#!/usr/bin/env ruby -w
|
||||
|
||||
#
|
||||
#
|
||||
@@ -136,9 +136,6 @@ class Glicko2
|
||||
add_result(opponent,Glicko2::DRAW)
|
||||
end
|
||||
|
||||
# Update rating based on current results list, and clear results.
|
||||
def update
|
||||
|
||||
# util func
|
||||
def Glicko2.g(deviation)
|
||||
1.0 / (Math.sqrt(1.0 + 3.0 * deviation ** 2.0 / (Math::PI ** 2.0)))
|
||||
@@ -149,9 +146,14 @@ class Glicko2
|
||||
1.0 / (1.0 + Math.exp(-Glicko2.g(deviation_opponent)*(rating - rating_opponent)));
|
||||
end
|
||||
|
||||
# Update rating based on current results list, and clear results.
|
||||
def update
|
||||
# util func
|
||||
|
||||
# bail if no opponents set
|
||||
if @results.empty?
|
||||
return nil
|
||||
@g2deviation = Math.sqrt(@g2deviation**2.0 + @g2volatility**2.0)
|
||||
return
|
||||
end
|
||||
|
||||
# compute variance
|
||||
|
||||
Regular → Executable
+3
-3
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env ruby
|
||||
#!/usr/bin/env ruby -w
|
||||
|
||||
require 'glicko2'
|
||||
require_relative 'glicko2'
|
||||
require 'test/unit'
|
||||
|
||||
class TestGlicko2 < Test::Unit::TestCase
|
||||
@@ -26,7 +26,7 @@ class TestGlicko2 < Test::Unit::TestCase
|
||||
a.update()
|
||||
|
||||
assert_in_delta(1464.05,a.rating,0.01)
|
||||
assert_in_delta(151.516,a.deviation,0.01)
|
||||
assert_in_delta(151.875,a.deviation,0.01)
|
||||
|
||||
end
|
||||
|
||||
|
||||
Reference in new issue
Block a user