State Management
How the VM manages world state.
Accessing State
const vm = new CruxVM(worldIR);
// Get current state
const state = vm.getState();
// Access specific data
console.log(state.tick);
console.log(state.agents);
console.log(state.events);Agent Queries
// Find agent by ID
const alice = vm.getAgent("agent_alice");
// Find agents by type
const visitors = vm.getAgentsByType("visitor");State Immutability
State is cloned from initial state using structuredClone.
Actions modify the cloned state, preserving the original for reset.
Resetting
// Reset to initial state
vm.reset();
// RNG is also reset to original seed