T0 + T1 + T2: engine redesign through new API surface #1

Merged
logaritmisk merged 45 commits from t2-new-api-surface into main 2026-04-24 11:20:04 +00:00
Showing only changes of commit c02d5ca0ab - Show all commits

View File

@@ -192,15 +192,19 @@ impl<'a, D: Drift> Game<'a, D> {
.map(|si| lhood_win[si] * lhood_lose[si])
.collect();
// Map sorted-team likelihoods back to original team order.
let order = arena.sort_buf.clone();
// Inverse permutation: inv[orig_i] = sorted_i (O(n), avoids clone + O(n²) search).
let mut inv = vec![0usize; n_teams];
for (si, &orig_i) in arena.sort_buf.iter().enumerate() {
inv[orig_i] = si;
}
self.likelihoods = self
.teams
.iter()
.zip(self.weights.iter())
.enumerate()
.map(|(orig_i, (players, weights))| {
let sorted_i = order.iter().position(|&x| x == orig_i).unwrap();
let sorted_i = inv[orig_i];
let m = m_t_ft[sorted_i];
let performance = players
.iter()