Skip to content

Commit aab201b

Browse files
authored
Merge pull request #89 from osu-tournament-rating/hotfix/cleanup-testing
Major cleanup and refactoring with testing and documentation improvements
2 parents 77d5bf9 + 88cf1c5 commit aab201b

File tree

10 files changed

+1339
-730
lines changed

10 files changed

+1339
-730
lines changed

Cargo.lock

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ strum_macros = "0.26.4"
3030
criterion = "0.5.1"
3131
tokio-postgres = { version = "0.7.11", features = ["with-chrono-0_4"] }
3232
postgres-types = "0.2.7"
33+
rand_chacha = "0.3.1"
34+
rand = "0.8.5"
35+
thiserror = "1.0.56"
36+
log = "0.4.22"
3337

3438
[dev-dependencies]
3539
criterion = { version = "0.5.1", features = ["html_reports"] }
@@ -40,7 +44,3 @@ unused_variables = "allow"
4044

4145
[profile.release]
4246
debug = true
43-
44-
[[bench]]
45-
name = "match_processing"
46-
harness = false

benches/match_processing.rs

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/database/db_structs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub struct GameScore {
5353
pub placement: i32
5454
}
5555

56-
#[derive(Debug, Clone, Serialize)]
56+
#[derive(Debug, Clone, Serialize, PartialEq)]
5757
pub struct PlayerRating {
5858
/// Unknown until insertion
5959
pub id: i32,
@@ -71,7 +71,7 @@ pub struct PlayerRating {
7171
pub adjustments: Vec<RatingAdjustment>
7272
}
7373

74-
#[derive(Debug, Clone, Serialize)]
74+
#[derive(Debug, Clone, Serialize, PartialEq)]
7575
pub struct RatingAdjustment {
7676
pub player_id: i32,
7777
pub ruleset: Ruleset,

src/model/constants.rs

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,55 @@
1-
// Model constants
2-
pub const MULTIPLIER: f64 = 60.0;
3-
pub const DEFAULT_VOLATILITY: f64 = 5.0 * MULTIPLIER;
4-
pub const DEFAULT_RATING: f64 = 15.0 * MULTIPLIER;
5-
pub const TAU: f64 = DEFAULT_VOLATILITY / 100.0;
1+
/// The absolute minimum rating any player can have, regardless of performance or decay
2+
pub const ABSOLUTE_RATING_FLOOR: f64 = 100.0;
3+
4+
/// Beta parameter for the PlackettLuce rating model
5+
/// Controls how quickly ratings change based on expected vs actual performance
66
pub const BETA: f64 = DEFAULT_VOLATILITY / 2.0;
7-
pub const KAPPA: f64 = 0.0001;
8-
pub const DECAY_DAYS: u64 = 121;
7+
8+
/// Number of days a player can be inactive before their rating begins to decay
9+
pub const DECAY_DAYS: u64 = 121; // Approximately 4 months
10+
11+
/// Minimum rating that any player can decay to, based on their peak rating
912
pub const DECAY_MINIMUM: f64 = 15.0 * MULTIPLIER;
13+
14+
/// Amount of rating lost per decay cycle
1015
pub const DECAY_RATE: f64 = 0.06 * MULTIPLIER;
11-
pub const ABSOLUTE_RATING_FLOOR: f64 = 100.0;
12-
// Default rating constants for osu!
13-
pub const OSU_RATING_FLOOR: f64 = MULTIPLIER * 5.0;
14-
pub const OSU_RATING_CEILING: f64 = MULTIPLIER * 30.0;
15-
pub const VOLATILITY_GROWTH_RATE: f64 = 0.08 * (MULTIPLIER * MULTIPLIER);
16+
17+
/// Initial volatility, higher values indicate more uncertainty in the rating
18+
pub const DEFAULT_VOLATILITY: f64 = 5.0 * MULTIPLIER;
19+
20+
/// Fallback default rating used when rating cannot be identified from osu! rank information
21+
pub const FALLBACK_RATING: f64 = 15.0 * MULTIPLIER;
22+
23+
/// Arbitrary regularization parameter
24+
pub const KAPPA: f64 = 0.0001;
25+
26+
/// Base multiplier used throughout the system to scale ratings
27+
/// This brings ratings into a more readable range (e.g., 900 instead of 15)
28+
pub const MULTIPLIER: f64 = 60.0;
29+
30+
/// Maximum possible initial rating in the osu! ruleset
31+
pub const OSU_INITIAL_RATING_CEILING: f64 = MULTIPLIER * 30.0; // 1800.0
32+
33+
/// Minimum possible initial rating in the osu! ruleset before decay
34+
pub const OSU_INITIAL_RATING_FLOOR: f64 = MULTIPLIER * 5.0; // 300.0
35+
36+
/// Scaling factor applied to rating changes based on performance frequency
37+
/// Lower values reduce the impact of infrequent participation
1638
pub const PERFORMANCE_SCALING_FACTOR: f64 = 0.3;
39+
40+
/// Tau parameter for the PlackettLuce rating model
41+
/// Controls the system's confidence in new ratings
42+
pub const TAU: f64 = DEFAULT_VOLATILITY / 100.0;
43+
44+
/// Rate at which volatility increases during decay periods
45+
/// Squared due to working with variance rather than standard deviation
46+
pub const DECAY_VOLATILITY_GROWTH_RATE: f64 = 0.08 * (MULTIPLIER * MULTIPLIER);
47+
48+
/// Weight applied to Method A in the final rating calculation
49+
/// Method A: Uses current rating for unplayed games
1750
pub const WEIGHT_A: f64 = 0.9;
51+
52+
/// Weight applied to Method B in the final rating calculation
53+
/// Method B: Assumes last place for unplayed games
54+
/// Always equals 1 - WEIGHT_A to ensure weights sum to 1
1855
pub const WEIGHT_B: f64 = 1.0 - WEIGHT_A;

0 commit comments

Comments
 (0)