From 5a7bb612e28b0c81b35652be26038e71c02008d6 Mon Sep 17 00:00:00 2001 From: Dean Rather Date: Thu, 26 Nov 2026 13:13:43 +1100 Subject: [PATCH] The Lake Hylia gate no longer opens by itself when dungeon entrances are shuffled With "Shuffle Dungeon Entrances" on and the Water Temple behind another dungeon's door, entering the temple there opened the gate at the bottom of Lake Hylia on the next visit, without the hookshot switch, giving a free way into whatever dungeon sits behind that gate. The gate now stays shut until its switch is hit. ## Cause The gate (`Obj_LakeHrl_SwitchShutter_A_01`) is driven by `Logic/HyruleField_LakeHylia_Common_Prefab_6a9d.logic.module.ainb`, run by both ages' Hyrule Field maps. Its OR opens the gate on `HavePlayedEvent.Dm_WaterTemple_0000` or directly on the Water Sage quest (`SageOfWater`) being past Step05, and the same quest check also writes the flag (element 16). The Water Temple's door carries `SageOfWater_Arrival_WaterTemple`, which moves the quest to Step06, and the shuffle moves that event with the dungeon. In the vanilla game the temple can only be entered through the gate, so neither path shows. With the temple moved, entering it opens the gate. ## Change `randomizer/core/src/entr/lake.rs`, called from `entr::story::stage`. Only when the seed's layout moves the Water Temple away from its own spot, the lake module is rewritten in two places: element 16's drive input becomes constant false, and the gate OR's multi-input entry that read the quest step reads the flag instead. Nothing then reads the quest step. The gate opens only on the flag, which only the switch's scene sets, as in the vanilla game. The switch, the scene request and the pillar are untouched, and the Water Sage quest still moves to Step06 when the temple is entered. The game's logic already requires the Hookshot for the Water Temple spot. `entr.rs`, `entr/build.rs`, `entr/story.rs`: the module declaration, one build-report line and the call. With `shuffle_entrances` off the stage returns before reading anything. With the Water Temple in place nothing is staged. ## Checked - Regression tests in `lake.rs` (game files): the unfixed module has 2 readers of the quest check, the patched one 0. Only the two edits differ. The scene request is `AND(NOT flag, switch OnState)` before and after. With only the first edit, 2 of the 5 lake tests fail. - `cargo test --workspace`: 2433 passed, 0 failed, 13 ignored. - Default output byte-identical to nightly 240af8b2: shuffle off 295 files identical. Dungeons shuffled with the Water Temple in place: 298 identical. With it moved, only the lake module differs. - In the game (scripted, same seed, fixed build and an unfixed control): entering the Water Temple by the Sacred Forest Meadow door leaves the flag 0 and the gate shut (the control opens it). Hookshotting the switch above the gate on the fixed build plays `Dm_WaterTemple_0000`, sets the flag and opens the gate, which stays open after a map reload and after a save reload. Co-Authored-By: Claude Opus 5.5 --- randomizer/core/src/entr.rs | 1 + randomizer/core/src/entr/build.rs | 3 + randomizer/core/src/entr/lake.rs | 361 ++++++++++++++++++++++++++++++ randomizer/core/src/entr/story.rs | 13 +- 4 files changed, 375 insertions(+), 3 deletions(-) create mode 100644 randomizer/core/src/entr/lake.rs diff --git a/randomizer/core/src/entr.rs b/randomizer/core/src/entr.rs index d03b38f5..97b86b41 100644 --- a/randomizer/core/src/entr.rs +++ b/randomizer/core/src/entr.rs @@ -1,5 +1,6 @@ pub mod build; pub mod data; +pub mod lake; pub mod layout; pub mod logic; pub mod mode; diff --git a/randomizer/core/src/entr/build.rs b/randomizer/core/src/entr/build.rs index 492a2c4b..c5e12516 100644 --- a/randomizer/core/src/entr/build.rs +++ b/randomizer/core/src/entr/build.rs @@ -211,6 +211,9 @@ pub fn apply(rf: &mut Romfs, seed: &SeedFile, edits: &mut Vec) -> Res = text::report(&l).lines().map(|x| x.to_string()).collect(); notes.push(format!("{} entrance actors were rewritten in {} map files for the dungeon entrances.", st.actors, st.files.len())); + if crate::entr::lake::moved(&l)? { + notes.push(crate::entr::lake::NOTE.to_string()); + } Ok(notes) } diff --git a/randomizer/core/src/entr/lake.rs b/randomizer/core/src/entr/lake.rs new file mode 100644 index 00000000..87ed1c76 --- /dev/null +++ b/randomizer/core/src/entr/lake.rs @@ -0,0 +1,361 @@ +use std::path::Path as P; + +use crate::ainb::Ainb; +use crate::entr::layout::Layout; +use crate::entr::pools::find; +use crate::door_open::multi_entry; +use crate::error::{Error as E, Res}; +use crate::romfs::Romfs; +use crate::staging::Out; + +pub const MODULE: &str = "Logic/HyruleField_LakeHylia_Common_Prefab_6a9d.logic.module.ainb"; +pub const WATER: &str = "Water Temple"; +pub const FLAG: &str = "HavePlayedEvent.Dm_WaterTemple_0000"; +pub const QUEST: &str = "Work/Challenge/SageOfWater.game__challenge__Challenge.gyml"; +pub const STEP: &str = "Step05"; +pub const NOTE: &str = "The Water Temple is not behind the Lake Hylia gate, so the gate opens only from its own switch."; + +const BOOL: usize = 1; +const SET: &str = "TriggerGameDataSetBoolTrue"; +const CHECK: &str = "HoldChallengeCurrentStepCheckOrder"; +const DRIVE: &str = "IsDrive"; +const GATE: &str = "ActorLogicGateDoor"; +const SHUTTER: &str = "Obj_LakeHrl_SwitchShutter_A_01"; +const READ: &str = "HoldGameDataGetBoolSimple"; + +pub fn moved(l: &Layout) -> Res { + l.check()?; + let w: usize = find(WATER).ok_or(E::Format("lake gate: the Water Temple is not in the dungeon pool"))?; + Ok(l.at[w] != w) +} + +fn is_step(a: &Ainb, j: usize) -> bool { + a.find_els(CHECK).contains(&j) && a.in_str(j, "ChallengeName") == Some(QUEST) && a.in_str(j, "ChallengeStepName") == Some(STEP) +} + +pub fn triggers(a: &Ainb) -> Vec { + a.find_els(SET) + .into_iter() + .filter(|&i| a.in_str(i, "GameDataNameBool") == Some(FLAG)) + .filter(|&i| a.find_in(i, BOOL, DRIVE).and_then(|g| a.input(BOOL, g)).is_some_and(|x| x.src >= 0 && is_step(a, x.src as usize))) + .collect() +} + +pub fn multis(a: &Ainb, i: usize) -> Vec { + let mut v: Vec = Vec::new(); + for g in a.input_ids(i, BOOL) { + if let Some(x) = a.input(BOOL, g).filter(|x| x.src <= -100) { + let b: usize = (-100 - x.src as i32) as usize; + v.extend(b..b + x.plug.max(0) as usize); + } + } + v +} + +pub fn gate_or(a: &Ainb) -> Option { + let doors: Vec = a.find_els(GATE).into_iter().filter(|&d| a.prop_str(d, "InstanceName").is_some_and(|n| n.starts_with(SHUTTER))).collect(); + let [d] = doors[..] else { return None }; + let src = |n: &str| a.find_in(d, BOOL, n).and_then(|g| a.input(BOOL, g)).map(|x| x.src).unwrap_or(-1); + let (o, c): (i16, i16) = (src("isOpen"), src("isClose")); + if o < 0 || o != c { + return None; + } + Some(o as usize) +} + +pub fn flag_read(a: &Ainb) -> Option { + let r: Vec = a.find_els(READ).into_iter().filter(|&j| a.in_str(j, "GameDataNameBool") == Some(FLAG)).collect(); + let [j] = r[..] else { return None }; + Some(j) +} + +pub fn gate_steps(a: &Ainb) -> Vec { + let Some(o) = gate_or(a) else { return Vec::new() }; + multis(a, o).into_iter().filter(|&j| multi_entry(a, j).is_some_and(|(n, _)| is_step(a, n as usize))).collect() +} + +pub fn cut(a: &mut Ainb) -> Res { + let hits: Vec = triggers(a); + let [i] = hits[..] else { + return Err(E::Msg(format!("lake gate: expected one {FLAG} write driven by the Water Sage {STEP} check, found {}, the module is not the game's", hits.len()))); + }; + let o: usize = gate_or(a).ok_or(E::Format("lake gate: the shutter is not opened by one OR element"))?; + let f: usize = flag_read(a).ok_or(E::Format("lake gate: the module does not read the gate flag once"))?; + let steps: Vec = gate_steps(a); + let flags: Vec = multis(a, o).into_iter().filter(|&j| multi_entry(a, j).is_some_and(|(n, _)| n as usize == f)).collect(); + let ([s], [p]) = (&steps[..], &flags[..]) else { + return Err(E::Format("lake gate: the shutter does not open on the gate flag or the Water Sage step, the module is not the game's")); + }; + if !a.force_bool(i, DRIVE, false)? { + return Err(E::Format("lake gate: the flag write had no link to cut")); + } + let from: [u8; 4] = a.multi.get(8 * p..8 * p + 4).and_then(|b| b.try_into().ok()).ok_or(E::Format("lake gate: bad multi entry"))?; + a.multi[8 * s..8 * s + 4].copy_from_slice(&from); + Ok(i) +} + +pub fn patch(raw: &[u8]) -> Res> { + let mut a: Ainb = Ainb::parse(raw)?; + cut(&mut a)?; + let out: Vec = a.write()?; + if Ainb::parse(&out)?.write()? != out { + return Err(E::Format("lake gate: the edited logic module does not read back as written")); + } + Ok(out) +} + +pub fn stage(rf: &Romfs, l: &Layout, late: &mut Vec, work: &P) -> Res { + if !moved(l)? { + return Ok(false); + } + if late.iter().any(|o| o.path == MODULE) { + return Err(E::Msg(format!("lake gate: {MODULE} is already edited in the late files"))); + } + let staged: std::path::PathBuf = MODULE.split('/').fold(work.to_path_buf(), |a, s| a.join(s)); + let raw: Vec = match std::fs::read(&staged) { + Ok(b) => b, + Err(_) => rf.read(MODULE)?, + }; + let out: Vec = patch(&raw)?; + late.push(Out { path: MODULE.to_string(), old: raw.len(), new: out.len(), z: out }); + Ok(true) +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::ainb::audit; + use crate::byml::{Byml, Node}; + use crate::entr::pools::DUNGEONS; + use std::path::PathBuf as PB; + + fn real() -> Option { + let p: PB = ootrr_game::test_romfs::path(); + if p.join("Pack").join("ZsDic.pack.zs").is_file() { + Some(Romfs::open(&p).unwrap()) + } else { + eprintln!("skipped, no RomFS dump at {} (set OOTRR_ROMFS)", p.display()); + None + } + } + + fn swap(a: &str, b: &str) -> Layout { + let mut l: Layout = Layout::vanilla(); + l.at.swap(find(a).unwrap(), find(b).unwrap()); + l + } + + type Link = (usize, usize, String, i16, Vec); + + fn links(a: &Ainb) -> Vec { + let mut v: Vec = Vec::new(); + for i in 0..a.els.len() { + for k in 0..6 { + for g in a.input_ids(i, k) { + let x = a.input(k, g).unwrap(); + v.push((i, k, a.s(x.name).to_string(), x.src, x.val)); + } + } + } + v + } + + fn gate_reads(a: &Ainb) -> Vec<(u16, u16)> { + let o: usize = gate_or(a).unwrap(); + let f: i16 = a.find_in(o, BOOL, "BoolMulti").and_then(|g| a.input(BOOL, g)).map(|x| x.src).unwrap(); + assert!(f <= -100); + multis(a, o).into_iter().map(|j| multi_entry(a, j).unwrap()).collect() + } + + fn opens_on_flag(a: &Ainb) -> bool { + let f: Option = flag_read(a); + f.is_some() && gate_reads(a).iter().any(|(n, p)| Some(*n as usize) == f && *p == 0) + } + + fn readers_of(a: &Ainb, e: usize) -> usize { + let mut n: usize = 0; + for i in 0..a.els.len() { + for k in 0..6 { + n += a.input_ids(i, k).into_iter().filter(|&g| a.input(k, g).is_some_and(|x| x.src == e as i16)).count(); + } + n += multis(a, i).into_iter().filter(|&j| multi_entry(a, j).is_some_and(|(m, _)| m as usize == e)).count(); + } + n + } + + fn steps_el(a: &Ainb) -> usize { + let v: Vec = (0..a.els.len()).filter(|&j| is_step(a, j)).collect(); + assert_eq!(v.len(), 1); + v[0] + } + + fn named(a: &Ainb, kind: &str, inst: &str) -> usize { + let v: Vec = a.find_els(kind).into_iter().filter(|&j| a.prop_str(j, "InstanceName").is_some_and(|n| n.starts_with(inst))).collect(); + assert_eq!(v.len(), 1, "{kind} {inst}"); + v[0] + } + + fn scene_request(a: &Ainb) -> (usize, Vec<(u16, u16)>) { + let r: usize = named(a, "ActorLogicEventRequestActor", "EventRequestActor_4eef"); + let x = a.input(BOOL, a.find_in(r, BOOL, "EventRequestTrigger").unwrap()).unwrap(); + assert!(x.src >= 0); + let and: usize = x.src as usize; + assert_eq!(a.el_name(and), "OperateAND"); + (r, multis(a, and).into_iter().map(|j| multi_entry(a, j).unwrap()).collect()) + } + + #[test] + fn only_a_layout_that_moves_the_water_temple_counts() { + assert!(!moved(&Layout::vanilla()).unwrap()); + assert!(!moved(&swap("Deku Tree", "Fire Temple")).unwrap()); + assert!(moved(&swap("Water Temple", "Forest Temple")).unwrap()); + let w: usize = find(WATER).unwrap(); + for d in (0..DUNGEONS.len()).filter(|d| *d != w) { + let l: Layout = swap(WATER, DUNGEONS[d].name); + assert!(moved(&l).unwrap(), "{}", DUNGEONS[d].name); + } + } + + #[test] + fn the_game_writes_the_gate_flag_from_the_water_sage_step_and_the_patch_cuts_only_that() { + let Some(rf) = real() else { + return; + }; + let raw: Vec = rf.read(MODULE).unwrap(); + let a: Ainb = Ainb::parse(&raw).unwrap(); + assert_eq!(a.write().unwrap(), raw); + let hits: Vec = triggers(&a); + println!("unfixed module: {} write(s) of {FLAG} driven by the Water Sage quest past {STEP}, elements {hits:?}", hits.len()); + assert_eq!(hits.len(), 1); + assert!(opens_on_flag(&a)); + let steps: Vec = gate_steps(&a); + println!("unfixed module: the shutter's OR also reads the {STEP} check directly at multi entries {steps:?}; gate reads {:?}", gate_reads(&a)); + assert_eq!(steps.len(), 1); + let out: Vec = patch(&raw).unwrap(); + println!("module bytes: {} unpatched, {} patched", raw.len(), out.len()); + let b: Ainb = Ainb::parse(&out).unwrap(); + assert!(triggers(&b).is_empty()); + assert!(gate_steps(&b).is_empty()); + assert!(opens_on_flag(&b)); + let f: u16 = flag_read(&b).unwrap() as u16; + assert!(gate_reads(&b).iter().all(|e| *e == (f, 0)), "{:?}", gate_reads(&b)); + assert_eq!(readers_of(&b, steps_el(&a)), 0); + let md: Vec = (0..a.multi.len() / 8).filter(|&j| multi_entry(&a, j) != multi_entry(&b, j)).collect(); + assert_eq!(md, steps); + assert_eq!(a.multi.len(), b.multi.len()); + assert!(audit(&b).is_empty(), "{:?}", audit(&b)); + let i: usize = hits[0]; + let x = b.input(BOOL, b.find_in(i, BOOL, DRIVE).unwrap()).unwrap(); + assert_eq!((x.src, x.val.iter().any(|v| *v != 0)), (-1, false)); + assert_eq!(b.in_str(i, "GameDataNameBool"), Some(FLAG)); + let names = |x: &Ainb| -> Vec<(u16, String, u32)> { (0..x.els.len()).map(|j| (x.el_type(j), x.el_name(j).to_string(), x.el_hash(j))).collect() }; + assert_eq!(names(&a), names(&b)); + let la: Vec = links(&a); + let lb: Vec = links(&b); + assert_eq!(la.len(), lb.len()); + let diff: Vec<(&Link, &Link)> = la.iter().zip(lb.iter()).filter(|(p, q)| p != q).collect(); + assert_eq!(diff.len(), 1); + assert_eq!((diff[0].0 .0, diff[0].0 .2.as_str()), (i, DRIVE)); + for j in (0..a.params.len()).filter(|j| *j != i) { + assert_eq!(a.params[j], b.params[j], "element {j}"); + } + assert!(patch(&out).is_err()); + } + + #[test] + fn nothing_is_staged_unless_the_water_temple_moved() { + let Some(rf) = real() else { + return; + }; + let work: &P = P::new("no such work folder"); + for l in [Layout::vanilla(), swap("Deku Tree", "Fire Temple"), swap("Jabu Jabus Belly", "Shadow Temple")] { + let mut late: Vec = Vec::new(); + assert!(!stage(&rf, &l, &mut late, work).unwrap()); + assert!(late.is_empty()); + } + let mut late: Vec = Vec::new(); + assert!(stage(&rf, &swap(WATER, "Forest Temple"), &mut late, work).unwrap()); + assert_eq!(late.len(), 1); + assert_eq!(late[0].path, MODULE); + assert!(triggers(&Ainb::parse(&late[0].z).unwrap()).is_empty()); + assert!(stage(&rf, &swap(WATER, "Forest Temple"), &mut late, work).is_err()); + } + + #[test] + fn the_module_is_the_only_lake_logic_that_writes_the_flag_and_both_ages_use_it() { + let Some(mut rf) = real() else { + return; + }; + let mut writers: Vec = Vec::new(); + for e in std::fs::read_dir(rf.root.join("Logic")).unwrap() { + let p: PB = e.unwrap().path(); + let n: String = p.file_name().unwrap().to_string_lossy().to_string(); + if !n.ends_with(".ainb") { + continue; + } + let a: Ainb = Ainb::parse(&std::fs::read(&p).unwrap()).unwrap(); + if a.find_els(SET).into_iter().any(|i| a.in_str(i, "GameDataNameBool") == Some(FLAG)) { + writers.push(format!("Logic/{n}")); + } + } + assert_eq!(writers, vec![MODULE.to_string()]); + let stem: &str = MODULE.trim_start_matches("Logic/").trim_end_matches(".logic.module.ainb"); + let mut users: Vec = Vec::new(); + for age in ["Adult", "Child"] { + for part in ["Static", "Dynamic"] { + let f: String = format!("Banc/HyruleField/HyruleField_{age}_{part}.bcett.byml.zs"); + let y: Byml = Byml::parse(&rf.read_zs(&f).unwrap()).unwrap(); + let groups: &[Node] = y.root.get("AiGroups").and_then(|g| g.as_arr()).unwrap_or(&[]); + if groups.iter().any(|g| g.get("Logic").and_then(|l| l.as_str()).is_some_and(|l| l.contains(stem))) { + users.push(f); + } + } + } + println!("maps that run {MODULE}: {users:?}"); + assert!(users.iter().any(|u| u.contains("_Adult_")), "{users:?}"); + assert!(users.iter().any(|u| u.contains("_Child_")), "{users:?}"); + } + + #[test] + fn the_switch_plays_the_gate_scene_and_after_the_patch_nothing_reads_the_water_sage_step() { + let Some(mut rf) = real() else { + return; + }; + let raw: Vec = rf.read(MODULE).unwrap(); + let a: Ainb = Ainb::parse(&raw).unwrap(); + let b: Ainb = Ainb::parse(&patch(&raw).unwrap()).unwrap(); + let st: usize = steps_el(&a); + println!("readers of the {STEP} check: unfixed {}, patched {}", readers_of(&a, st), readers_of(&b, st)); + assert_eq!(readers_of(&a, st), 2); + assert_eq!(readers_of(&b, st), 0); + for m in [&a, &b] { + let f: u16 = flag_read(m).unwrap() as u16; + let sw: usize = named(m, "ActorLogicBootUpForceControlActor", "Obj_LakeHrl_SwitchHit_A_01"); + let (_, req): (usize, Vec<(u16, u16)>) = scene_request(m); + assert_eq!(req.len(), 2); + assert_eq!(req[1], (sw as u16, 3)); + let (n, p): (usize, u16) = (req[0].0 as usize, req[0].1); + let x = m.input(BOOL, m.find_in(n, BOOL, "BoolMulti").unwrap()).unwrap(); + assert_eq!((m.el_name(n), x.src, x.plug, p), ("OperateAND", f as i16, 0, 0)); + } + assert_eq!(scene_request(&a), scene_request(&b)); + let ev: &str = FLAG.trim_start_matches("HavePlayedEvent."); + for age in ["Adult", "Child"] { + let f: String = format!("Banc/HyruleField/HyruleField_{age}_Static.bcett.byml.zs"); + let y: Byml = Byml::parse(&rf.read_zs(&f).unwrap()).unwrap(); + let groups: &[Node] = y.root.get("AiGroups").and_then(|g| g.as_arr()).unwrap(); + let stem: &str = MODULE.trim_start_matches("Logic/").trim_end_matches(".logic.module.ainb"); + let g: Vec<&Node> = groups.iter().filter(|g| g.get("Logic").and_then(|l| l.as_str()).is_some_and(|l| l.contains(stem))).collect(); + assert_eq!(g.len(), 1, "{f}"); + let refs: &[Node] = g[0].get("References").and_then(|r| r.as_arr()).unwrap(); + let ids: Vec<&str> = refs.iter().filter_map(|r| r.get("Id").and_then(|i| i.as_str())).collect(); + assert_eq!(ids, vec!["EventRequestActor_4eef", "Obj_LakeHrl_SwitchHit_A_01_e78f", "Obj_LakeHrl_SwitchShutter_A_01_62c7", "Obj_LakeHrl_GatePillar_A_01_1a55"], "{f}"); + let h: &Node = refs[0].get("Reference").unwrap(); + let actors: &[Node] = y.root.get("Actors").and_then(|x| x.as_arr()).unwrap(); + let act: Vec<&Node> = actors.iter().filter(|x| x.get("Hash") == Some(h)).collect(); + assert_eq!(act.len(), 1, "{f}"); + assert_eq!(act[0].get("Gyaml").and_then(|x| x.as_str()), Some("EventRequestActor")); + assert_eq!(act[0].get("Dynamic").and_then(|d| d.get("RequestEventName")).and_then(|x| x.as_str()), Some(ev), "{f}"); + } + } +} diff --git a/randomizer/core/src/entr/story.rs b/randomizer/core/src/entr/story.rs index a04d71f6..1268649f 100644 --- a/randomizer/core/src/entr/story.rs +++ b/randomizer/core/src/entr/story.rs @@ -227,6 +227,7 @@ pub fn stage(rf: &mut Romfs, seed: &SeedFile, late: &mut Vec, work: &P) -> return Ok(()); } let l: Layout = Layout::from_map(&seed.entrances)?; + crate::entr::lake::stage(rf, &l, late, work)?; let cat: Cat = load()?; let Some(d) = dest(rf, &cat, &l)? else { return Ok(()); @@ -387,10 +388,16 @@ mod tests { .find(|g| Layout::from_map(&g.seed_file.entrances).is_ok_and(|l| l.at[j] != j)) .unwrap(); stage(&mut rf, &on.seed_file, &mut late, work).unwrap(); - let paths: Vec<&str> = late.iter().map(|o| o.path.as_str()).collect(); - assert_eq!(paths, vec![format!("Event/EventFlow/{FLOW}.bfevfl.zs").as_str()]); - let b: Bf = Bf::parse(&rf.zs.decompress(&late[0].z).unwrap()).unwrap(); let l: Layout = Layout::from_map(&on.seed_file.entrances).unwrap(); + let flow_path: String = format!("Event/EventFlow/{FLOW}.bfevfl.zs"); + let mut want_paths: Vec<&str> = vec![flow_path.as_str()]; + if crate::entr::lake::moved(&l).unwrap() { + want_paths.insert(0, crate::entr::lake::MODULE); + } + let paths: Vec<&str> = late.iter().map(|o| o.path.as_str()).collect(); + assert_eq!(paths, want_paths); + let fl: &Out = late.iter().find(|o| o.path == flow_path).unwrap(); + let b: Bf = Bf::parse(&rf.zs.decompress(&fl.z).unwrap()).unwrap(); let want: &str = DUNGEONS[l.at[j]].map; assert!(changes(flow(&b), EAT).iter().all(|(m, ..)| m == want)); }