Your First World
Build a complete simulation from scratch.
What We'll Build
A small park simulation with visitors who wander around, get tired, and rest to recover energy.
Step 1: World Setup
crux
world Park {
seed: 42
tick_rate: 1
version: "1.0.0"
description: "A simple park simulation"
}Step 2: Add Agents
crux
agent alice: visitor {
position: { x: 10, y: 10 }
energy: 100
}
agent bob: visitor {
position: { x: 50, y: 50 }
energy: 80
}Step 3: Define Behaviors
crux
rule wander {
priority: 1
select: { type: "visitor" }
when energy > 20
do wander(speed: 2)
}
rule rest {
priority: 2
select: { type: "visitor" }
when energy <= 20
do rest(recovery: 10)
}Step 4: Run It
bash
cruxos compile park.crux
cruxos run park.cxir --ticks 50