refactor!: close the remaining API gaps from #21
Three unrelated small defects, all requiring signature changes: - `Game::one_v_one` hardcoded `GameOptions::default()`, so a 1v1 could never set `p_draw` or convergence options — and a drawn 1v1 was therefore unreachable through it, since the default `p_draw` is zero. It now takes `&GameOptions` like every other constructor. - `Observer::on_batch_processed` was declared on the trait and never called from anywhere: implementors wired up a callback that could not fire. It is now called after each slice sweep, and renamed `on_slice_processed` to match the vocabulary the codebase adopted in T2 — the unit of work is a `TimeSlice`, not a batch. A slice is swept once travelling backward and once forward, so a multi-slice history fires it twice per slice per iteration; the doc comment says so. - `pub mod factors` sat beside `pub(crate) mod factor`, two module paths differing by one character with only one of them importable. The public facade is now `graph`. Tests cover each as a behaviour rather than a compile check: a drawn 1v1 succeeds only when p_draw is supplied, and the observer tests fail if any callback stops firing. BREAKING CHANGE: `Game::one_v_one` takes a fourth `&GameOptions` argument; `Observer::on_batch_processed` is renamed `on_slice_processed`; the `factors` module is renamed `graph`. Closes #21 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011hcFjNDmHXZF8URGLku5zZ
This commit is contained in:
@@ -261,6 +261,11 @@ impl<T: Time, D: Drift<T>, O: Observer<T>, K: Eq + Hash + Clone> History<T, D, O
|
||||
let old = self.time_slices[j].posteriors();
|
||||
|
||||
self.time_slices[j].new_backward_info(&self.agents);
|
||||
self.observer.on_slice_processed(
|
||||
&self.time_slices[j].time,
|
||||
j,
|
||||
self.time_slices[j].events.len(),
|
||||
);
|
||||
|
||||
let new = self.time_slices[j].posteriors();
|
||||
|
||||
@@ -280,6 +285,11 @@ impl<T: Time, D: Drift<T>, O: Observer<T>, K: Eq + Hash + Clone> History<T, D, O
|
||||
let old = self.time_slices[j].posteriors();
|
||||
|
||||
self.time_slices[j].new_forward_info(&self.agents);
|
||||
self.observer.on_slice_processed(
|
||||
&self.time_slices[j].time,
|
||||
j,
|
||||
self.time_slices[j].events.len(),
|
||||
);
|
||||
|
||||
let new = self.time_slices[j].posteriors();
|
||||
|
||||
@@ -292,6 +302,11 @@ impl<T: Time, D: Drift<T>, O: Observer<T>, K: Eq + Hash + Clone> History<T, D, O
|
||||
let old = self.time_slices[0].posteriors();
|
||||
|
||||
self.time_slices[0].iteration(0, &self.agents);
|
||||
self.observer.on_slice_processed(
|
||||
&self.time_slices[0].time,
|
||||
0,
|
||||
self.time_slices[0].events.len(),
|
||||
);
|
||||
|
||||
let new = self.time_slices[0].posteriors();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user