int_world::{decode, decode_deltas, decode_planes} render through world/1 and
return a Result; int_world::{load, World} hold the set lowered and loaded once,
with step, step_delta, step_action and render for the live path, which replace
the per-row step functions of a parsed model. int_world::legacy is test-only
(legacy_int). wai-web's WorldModel loads its set once and renders through it;
its methods throw on a refusal.
Callers moved: tests int_world, int_world2, int_world_shared,
int_kernels_vectors; the int_world_decode example; the decode bench's world
row. tests/int_world_memory.rs (its own binary; both fast-kernel steps): a
clip, a step and a frame hold no more than the direct renderer's.
Text: integer-operators' status note, §13.5 (before the first frame: the
plan, T giving the shape back, the informative codes), §15.3 items 2 and 3;
SPEC §8's planned breaks; CHANGELOG.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
29 lines
1.6 KiB
Rust
29 lines
1.6 KiB
Rust
//! 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 -- <dir> [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 <dir> [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<i64> = j["z0"].as_array().unwrap().iter().map(|v| v.as_i64().unwrap()).collect();
|
|
let actions: Vec<usize> = 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<u8> = clip.frames.iter().flatten().copied().collect();
|
|
std::fs::write(out, bytes).unwrap();
|
|
}
|
|
}
|