Skip to main content
Verticopolis engineGitHub

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 (Simulation::serialize) without the log messages’ text and the pending choice’s message, so wording changes never move a hash.