refactor(api): rename Agent to Competitor and .player field to .rating

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.
This commit is contained in:
2026-04-24 10:48:50 +02:00
parent 88d54cb9f4
commit decbd895a3
9 changed files with 219 additions and 212 deletions

50
src/competitor.rs Normal file
View File

@@ -0,0 +1,50 @@
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;
}
}
}