Skip to main content
Verticopolis engine

Module snapshot

Module snapshot 

Source
Expand description

The hashed state view: the saved game without its prose, which the conformance suite hashes at every checkpoint. Hash it with crate::canonical::digest to tell whether two games are in the same state.

use verticopolis_engine::canonical::digest;
use verticopolis_engine::clock::GameMode;
use verticopolis_engine::sim::Simulation;
use verticopolis_engine::snapshot::state_view;

let mut a = Simulation::new_game(9, GameMode::Classic);
let mut b = Simulation::new_game(9, GameMode::Classic);
a.tick(120.0);
b.tick(60.0);
b.tick(60.0);
assert_eq!(digest(&state_view(&a)), digest(&state_view(&b)));

Functions§

state_view
The saved game with every unit listed on its own (Simulation::serialize_unfolded, so the floor-run encoding never moves a hash), without the log messages’ text and the pending choice’s message, so wording changes never move a hash, and without the crowd, which the conformance suite hashes as its own channel ([crate::crowd::Crowd::view]), the cars’ timers mid-stop, the housekeeping tallies, the day’s move-ins or a first-day game’s period marks, which the hash has never held. They show in the hash through what they decide: whether the morning checkout line, the housekeeping nudges and the evening’s “New tenants:” line are logged, and the money the first day’s end bills.