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 { pub rating: Rating, pub message: Gaussian, pub last_time: i64, } impl Competitor { 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 { fn default() -> Self { Self { rating: Rating::default(), message: N_INF, last_time: i64::MIN, } } } pub(crate) fn clean<'a, D: Drift + 'a, C: Iterator>>( competitors: C, last_time: bool, ) { for c in competitors { c.message = N_INF; if last_time { c.last_time = i64::MIN; } } }