Share a state machine between browser and canister
The p2pgame arena prototype uses one Rust reducer in browser Wasm and on the Internet Computer. The browser predicts movement locally and the canister commits accepted checkpoints and scores.
The same rules run in two places
A player needs to see movement as soon as they press a key. The p2pgame prototype builds icgame-engine into browser Wasm and the IC referee. The engine uses fixed-point coordinates and ordered tick inputs, so identical starting state, input and rules give the same transition. The browser predicts from its local view while JavaScript handles browser I/O and rendering. In the same Wasm heap, the client uses Nyxus for local state, Reactor for batching audit traffic and Takt for workflows that call the IC.
When a checkpoint arrives, Game::reconcile checks it, adopts the accepted player view and replays pending inputs from that point. The browser can keep displaying responsive movement as it corrects its prediction. On the canister, prepare_referee verifies signed inputs and runs the simulation over a bounded window. commit_referee checks the prepared result against the current accepted parent and commits the checkpoint. Only that path can settle scores.
What to share
Keep transition rules in one crate and pass in the state and ordered inputs. Decide in the caller what listeners can see, which inputs count and who can commit the result. This also works for a browser preview of a form, simulation or workflow whose final state belongs to a canister.
The native test own_only_prediction_is_identical_to_shared_authoritative_movement compares player state and movement flags across 300 ticks. That checks the shared movement rule. Real-peer playability is still being qualified for the current prototype.