flybrain/tools/scorecard/with-reader.patch
acamilo 49bae21a4d scorecard: a multi-seed good-play regression harness (fly-scorecard)
A fixed checkpoint set x seeds x brain minutes on the real connectome, on the session runtime or the legacy loop, reduced to JSON: rungs per hour, empty pad, watchdog check 10 rules, ladder-worthy traps, the shop-to-catch funnel, heals, whiteouts, battles, blocked macros. Compare mode pairs two cards by (checkpoint, seed) and judges each metric with a sign-flip permutation test and a tolerance. PokeredTask gains a read-only with_reader for the harness.
2026-10-02 02:28:15 +00:00

24 lines
1 KiB
Diff

diff --git a/services/flysim/crates/fly-legacy-session/src/task.rs b/services/flysim/crates/fly-legacy-session/src/task.rs
index f85694e..2cd14c2 100644
--- a/services/flysim/crates/fly-legacy-session/src/task.rs
+++ b/services/flysim/crates/fly-legacy-session/src/task.rs
@@ -368,6 +368,19 @@ impl PokeredTask {
)
}
+ /// Read the committed boundary's memory image through the cartridge, as the macro engine
+ /// reads it, for a harness that measures play (the scorecard). `None` before the first
+ /// observation. Changes nothing.
+ pub fn with_reader<R>(
+ &self,
+ f: impl FnOnce(&mut dyn flybrain_gb::MemoryReader) -> R,
+ ) -> Option<R> {
+ let inner = self.lock();
+ let (_, image) = inner.current.as_ref()?;
+ let mut reader = ImageReader::new(image, &inner.cartridge);
+ Some(f(&mut reader))
+ }
+
/// The brain time of the last transition (its Prepare's clock), in ms: `network.ms`.
pub fn brain_ms(&self) -> f64 {
self.lock().ms