Competitor holds dynamic per-history state (message, last_time) for someone competing; its configuration lives in a Rating. AgentStore renamed to CompetitorStore to match. The internal `clean()` free function's parameter name changed from `agents` to `competitors` for consistency. Local variable names (agent_idx, this_agent) inside history.rs are left unchanged — they represent abstract identifiers, not Competitor instances. Part of T2 of docs/superpowers/specs/2026-04-23-trueskill-engine-redesign-design.md.
51 lines
1.2 KiB
Rust
51 lines
1.2 KiB
Rust
use crate::{
|
|
N_INF,
|
|
drift::{ConstantDrift, Drift},
|
|
gaussian::Gaussian,
|
|
rating::Rating,
|
|
};
|
|
|
|
/// Per-history, temporal state for someone competing.
|
|
///
|
|
/// Renamed from `Agent` in T2; the former `.player` field is now
|
|
/// `.rating` to match the `Player → Rating` rename.
|
|
#[derive(Debug)]
|
|
pub struct Competitor<D: Drift = ConstantDrift> {
|
|
pub rating: Rating<D>,
|
|
pub message: Gaussian,
|
|
pub last_time: i64,
|
|
}
|
|
|
|
impl<D: Drift> Competitor<D> {
|
|
pub(crate) fn receive(&self, elapsed: i64) -> Gaussian {
|
|
if self.message != N_INF {
|
|
self.message
|
|
.forget(self.rating.drift.variance_delta(elapsed))
|
|
} else {
|
|
self.rating.prior
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Default for Competitor<ConstantDrift> {
|
|
fn default() -> Self {
|
|
Self {
|
|
rating: Rating::default(),
|
|
message: N_INF,
|
|
last_time: i64::MIN,
|
|
}
|
|
}
|
|
}
|
|
|
|
pub(crate) fn clean<'a, D: Drift + 'a, C: Iterator<Item = &'a mut Competitor<D>>>(
|
|
competitors: C,
|
|
last_time: bool,
|
|
) {
|
|
for c in competitors {
|
|
c.message = N_INF;
|
|
if last_time {
|
|
c.last_time = i64::MIN;
|
|
}
|
|
}
|
|
}
|