Skip to content

Commit

Permalink
try unrestricted rating regulator
Browse files Browse the repository at this point in the history
restricted deviance was: 0.291317
  • Loading branch information
niklasf committed Nov 2, 2024
1 parent 69616a9 commit 465856d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 7 deletions.
24 changes: 24 additions & 0 deletions research/report-restricted-rating-regulator.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
min_deviation,max_deviation,default_volatility,tau,first_advantage,rating_periods_per_day,avg_deviance
45,500,0.09,0.75,12,0.21436,0.291317
# ---
# Sample Blitz rating of thibault: 1829.3 (rd: 52.789, vola: 0.08004)
# Sample Blitz rating of german11: 1424.7 (rd: 45.000, vola: 0.09986)
# Sample Bullet rating of revoof: 1787.6 (rd: 125.192, vola: 0.08717)
# Sample Bullet rating of drnykterstein: 2921.3 (rd: 82.219, vola: 0.07730)
# Sample Bullet rating of penguingim1: 3113.5 (rd: 45.000, vola: 0.08118)
# Sample Blitz rating of lance5500: 2769.0 (rd: 54.509, vola: 0.07154)
# Sample Blitz rating of somethingpretentious: 2247.3 (rd: 45.000, vola: 0.06258)
# Sample Blitz rating of tbest: 2427.4 (rd: 61.639, vola: 0.08204)
# Sample Classical rating of igormezentsev: 2513.8 (rd: 64.433, vola: 0.08854)
# ---
# Estimated UltraBullet distribution: p1=1341.0 p10=1476.5 p50=1804.8 p90=2259.1 p99=2372.5, avg=1833.7
# Estimated Bullet distribution: p1=882.5 p10=1190.8 p50=1753.4 p90=2224.8 p99=2576.4, avg=1732.7
# Estimated Blitz distribution: p1=841.6 p10=1127.2 p50=1660.9 p90=2107.0 p99=2443.1, avg=1643.9
# Estimated Rapid distribution: p1=382.5 p10=704.3 p50=1225.2 p90=1691.9 p99=1986.8, avg=1213.9
# Estimated Classical distribution: p1=1118.8 p10=1216.0 p50=1582.3 p90=1841.1 p99=1956.5, avg=1546.1
# Estimated Correspondence distribution: p1=1801.6 p10=1801.6 p50=1994.2 p90=1994.2 p99=1994.2, avg=1897.9
# ---
# Distinct players: 18198891
# Processed encounters: 6012388632 (last at: 2024-09-30 23:59:54)
# Total errors: 0
# ---
25 changes: 18 additions & 7 deletions src/rating_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@ impl RatingSystemBuilder {
self
}

/// Factor by which to nudge rating gains to counteract natural deflation.
/// Defaults to `1.02`.
pub fn regulator_factor(&mut self, regulator_factor: f64) -> &mut Self {
assert!(regulator_factor >= 0.0);
self.regulator_factor = regulator_factor;
self
}

pub fn build(&self) -> RatingSystem {
assert!(self.min_rating <= self.max_rating);
assert!(self.min_deviation <= self.max_deviation);
Expand Down Expand Up @@ -234,7 +242,7 @@ impl RatingSystem {

max_rating_delta: RatingDifference(700.0),

regulator_factor: 1.02, // XXX
regulator_factor: 1.02,
}
}

Expand Down Expand Up @@ -294,6 +302,10 @@ impl RatingSystem {
self.max_rating_delta
}

pub fn regulator_factor(&self) -> f64 {
self.regulator_factor
}

/// Construct an initial rating for a new player.
pub fn new_rating(&self) -> Rating {
Rating {
Expand Down Expand Up @@ -460,12 +472,11 @@ impl RatingSystem {
}

fn regulate(&self, rating: RatingScalar, delta: RatingDifference) -> RatingScalar {
let factor =
if delta > RatingDifference(0.0) && rating < self.default_rating + self.max_deviation {
self.regulator_factor
} else {
1.0
};
let factor = if delta > RatingDifference(0.0) && rating != self.default_rating {
self.regulator_factor
} else {
1.0
};

rating + (factor * delta).clamp(-self.max_rating_delta, self.max_rating_delta)
}
Expand Down

0 comments on commit 465856d

Please sign in to comment.