//! Decode an interactive world-model clip dir (`world_T.bin`, `world_gs.bin`, //! `world.json`, from `tools/wai_int_world_export.py`) → RGB frames; print the clip //! hash + frame-0 hash, optionally dump the raw frames. Proves the Rust integer world //! decode reproduces the Python integer reference byte-for-byte. //! //! cargo run --release --example int_world_decode --features world_int -- [out.rgb] use wai::int_hyper_synth::IntModel; use wai::int_world::decode; fn main() { let dir = std::env::args().nth(1).expect("usage: int_world_decode [out.rgb]"); let t = IntModel::from_bytes(&std::fs::read(format!("{dir}/world_T.bin")).unwrap()).unwrap(); let gs = IntModel::from_bytes(&std::fs::read(format!("{dir}/world_gs.bin")).unwrap()).unwrap(); let j: serde_json::Value = serde_json::from_slice(&std::fs::read(format!("{dir}/world.json")).unwrap()).unwrap(); let c = j["c"].as_u64().unwrap() as usize; let lat = j["lat"].as_u64().unwrap() as usize; let z0: Vec = j["z0"].as_array().unwrap().iter().map(|v| v.as_i64().unwrap()).collect(); let actions: Vec = j["actions"].as_array().unwrap().iter().map(|v| v.as_u64().unwrap() as usize).collect(); let clip = decode(&t, &gs, &z0, &actions, c, lat).unwrap_or_else(|r| panic!("the world renderer refused the clip: {r}")); println!("frames {} {}x{} frame0 {:016x} clip {:016x}", clip.frames.len(), clip.frame_px, clip.frame_px, clip.frame_hash(0), clip.clip_hash()); if let Some(out) = std::env::args().nth(2) { let bytes: Vec = clip.frames.iter().flatten().copied().collect(); std::fs::write(out, bytes).unwrap(); } }