Default tau to nil so rate checks env instead of options
Assisted-by: Claude Opus 4.6 via pi
change uvxyywsrrourxlwtxzulxrryovopxqty
commit 7013f6363ffe9a3e027b1039998873337f611cf4
author Alpha Chen <alpha@kejadlen.dev>
date
parent kmryzvun
diff --git a/lib/open_skill/constants.rb b/lib/open_skill/constants.rb
index 6b0f567..6611428 100644
--- a/lib/open_skill/constants.rb
+++ b/lib/open_skill/constants.rb
@@ -14,7 +14,7 @@ module OpenSkill
     target = options.fetch(:target, 0)
     prevent_sigma_increase = options.fetch(:prevent_sigma_increase, false)
 
-    tau = options.fetch(:tau, mu / 300.0)
+    tau = options[:tau]
     sigma = options.fetch(:sigma, mu.to_f / z)
     beta = options.fetch(:beta, sigma / 2.0)
     limit_sigma = options.fetch(:limit_sigma, prevent_sigma_increase)
diff --git a/lib/open_skill/rate.rb b/lib/open_skill/rate.rb
index 66eb89e..02b1ef4 100644
--- a/lib/open_skill/rate.rb
+++ b/lib/open_skill/rate.rb
@@ -9,7 +9,7 @@ module OpenSkill
     processed_teams = teams
 
     # If tau is provided, use additive dynamics factor to keep ratings pliable
-    if options.key?(:tau)
+    if env.tau
       tau_sq = env.tau**2
       processed_teams = teams.map { |team|
         team.map { |p| Rating.new(p.mu, Math.sqrt(p.sigma**2 + tau_sq)) }
@@ -29,7 +29,7 @@ module OpenSkill
     result = rank.zip(new_ratings).sort_by(&:first).map(&:last)
 
     # Cap sigma at pre-tau value so ordinal never drops after a win
-    if options.key?(:tau) && env.limit_sigma
+    if env.tau && env.limit_sigma
       result = result.map.with_index { |team, i|
         team.map.with_index { |p, j|
           Rating.new(p.mu, [p.sigma, teams[i][j].sigma].min)
diff --git a/test/test_open_skill.rb b/test/test_open_skill.rb
index 8f680e0..8dc63ce 100644
--- a/test/test_open_skill.rb
+++ b/test/test_open_skill.rb
@@ -110,12 +110,11 @@ class TestConstants < Minitest::Test
     env = OpenSkill.constants(mu: 300)
     assert_equal 50, env.beta
     assert_equal 2500, env.beta_sq
-    assert_in_delta 1, env.tau
     assert_equal 3, env.z
   end
 
-  def test_tau_default
-    assert_in_delta 0.08333333, OpenSkill.constants.tau
+  def test_tau_defaults_to_nil
+    assert_nil OpenSkill.constants.tau
   end
 
   def test_tau_accepts_override