Commit Graph

15 Commits

Author SHA1 Message Date
244b94a3e5 feat(api): typed add_events(iter); generify internal path over T
Public API gains:

  History::add_events<I: IntoIterator<Item = Event<T, K>>>(events)
      -> Result<(), InferenceError>

which accepts the typed Event<T, K> shape added in Task 10. Ranks
from Outcome::Ranked are mapped to the legacy "higher f64 = better"
results internally.

add_events_with_prior now takes Vec<T> for times (was Vec<i64>),
generifying the whole internal path over T in a single fully-generic
impl<T: Time, D: Drift<T>, O: Observer<T>, K> block. The i64-specific
block is gone; record_winner/record_draw are now generic over T.

add_events_with_prior stays pub (not pub(crate)) because the ATP
example calls it directly with pre-built Index-based composition;
the new typed add_events is the primary public API going forward.

In-crate tests updated to call add_events_with_prior with an empty
HashMap. tests/api_shape.rs added with 3 integration tests covering
bulk ingest, draw, and mismatched-outcome error.

Part of T2 of docs/superpowers/specs/2026-04-23-trueskill-engine-redesign-design.md.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-24 12:39:46 +02:00
a83c9acacb feat(error): expand InferenceError; convert boundary asserts to Result
InferenceError gains MismatchedShape (user-input length mismatches),
InvalidProbability (p_draw out of [0, 1]), and ConvergenceFailed
(exceeded max_iter without hitting epsilon). NegativePrecision stays.

History::add_events_with_prior and History::add_events now return
Result<(), InferenceError>. The previous assert! macros checking
composition/results/times/weights shape are replaced by matched
error returns.

Internal debug_assert! macros for arithmetic invariants stay; this
change only affects boundary validation of user input.

Tests updated to call .unwrap() on the Result. The old signatures
will be fully replaced in Task 15 (typed add_events(iter)) and the
nested-Vec wrapper removed in Task 20.

Part of T2 of docs/superpowers/specs/2026-04-23-trueskill-engine-redesign-design.md.
2026-04-24 12:26:13 +02:00
c69fe4e67c refactor(api): rename IndexMap to KeyTable
The former name collided with the popular indexmap crate. KeyTable
lives in its own module. Public API unchanged beyond the rename.

Part of T2 of docs/superpowers/specs/2026-04-23-trueskill-engine-redesign-design.md.
2026-04-24 10:34:14 +02:00
a667deb7e1 refactor(gaussian): switch to natural-parameter storage (pi, tau)
Mul and Div become two f64 adds/subs with no sqrt in the hot path.
mu() and sigma() are computed on demand from stored pi/tau.

Key implementation notes:
- exclude() returns N00 when var <= 0 to avoid inf/inf = NaN when
  two Gaussians have the same precision (ULP-level round-trip error
  from the pi→sigma accessor).
- Mul<f64> by 0.0 returns N00 (point mass at 0), matching old behavior.
- from_ms(0, 0) == N00 {pi:inf, tau:0}; from_ms(0, inf) == N_INF {pi:0, tau:0}.

Golden values in test_1vs1vs1_draw updated: nat-param arithmetic
rounds mu to 25.0 (was 24.999999) and shifts sigma by ~3e-7.
Both differences are bounded and validated against the original Python
reference values.

Part of T0 engine redesign.
2026-04-24 06:59:43 +02:00
04d5478ee4 style: cargo fmt 2026-04-23 20:23:13 +02:00
2bdd3d9b89 Remove warnings and refactor some code 2022-12-16 19:46:01 +01:00
18d55a8ccf Clean up example 2022-07-04 23:13:57 +02:00
32df04fb6d Small change 2022-06-28 23:29:44 +02:00
22c61d47b1 Change time to use i64 instead of u64 2022-06-28 23:18:55 +02:00
0633c766a5 Update example so now it works, and thats, well, good 2022-06-27 10:22:26 +02:00
dc10504b80 Port from julia version instead 2022-06-18 22:27:38 +02:00
0a3327f076 Refactor some code 2022-06-15 11:27:24 +02:00
9b025fb53a Use PlayerIndex instead of String 2022-06-14 22:51:11 +02:00
3fbac02de3 It works, or so it seems 2022-06-13 23:18:19 +02:00
1b6e07225b Handle case where there is no time 2022-06-13 21:55:43 +02:00