Core Concepts
Understanding the fundamental principles that make cruxOS tick.
Determinism
Determinism is the core principle of cruxOS. Given the same inputs, a world will always evolve in exactly the same way.
same IR + same seed = same world evolutionWhy Determinism Matters
- Reproducibility — Run simulations again and get identical results
- Debugging — Replay exact scenarios to find bugs
- Verification — Prove outcomes are legitimate
- Sharing — Exchange seeds instead of entire state histories
Seeded Randomness
cruxOS uses a deterministic pseudo-random number generator (PRNG). The seed in your world metadata initializes this PRNG, ensuring "random" events are actually
predictable given the seed.
// ❌ Non-deterministic
const value = Math.random();
// ✅ Deterministic
const value = vm.getRNG().next();Worlds
A World is a self-contained simulation environment. It holds all state and rules needed to evolve over time.
World Components
- metadata
- Name, version, seed, tick rate, and configuration
- initialState
- Starting snapshot: agents, zones, fields, events, globals
- rules
- Logic that transforms state each tick
Agents
Agents are the primary entities in a world. They have positions, internal state, and respond to rules.
interface Agent {
id: string; // Unique identifier
type: string; // Agent type (e.g., "visitor", "bird")
position: { // Spatial location
x: number;
y: number;
z?: number;
};
state: Record; // Custom state (mood, energy, etc.)
tags: string[]; // Classification tags
inbox: Message[]; // Received messages
outbox: Message[]; // Messages to send
}Agent Communication
Agents communicate through messages. Each tick, the VM:
- Processes rules (agents can add to
outbox) - Delivers all
outboxmessages to recipients'inbox - Clears outboxes
Messages sent this tick arrive next tick. This ensures determinism — all agents see the same state within a single tick.
Rules
Rules define how the world evolves. Each tick, rules are evaluated and actions are executed.
{
"id": "rule_wander",
"name": "Visitors wander around",
"priority": 10,
"selector": { "type": "visitor" },
"condition": "energy >= 30",
"action": "wander",
"params": { "speed": 3 }
}Rule Execution Flow
Selectors
Selectors determine which agents a rule applies to:
type— Match by agent typetags— Match by tags (agent must have ALL specified)ids— Match by specific IDs
Conditions
Conditions are expressions evaluated against agent state.
Supported operators: ==, !=, >, <, >=, <=, &&, ||
Ticks & Time
A tick is the smallest unit of simulation time. Each tick:
- Clear previous tick's events
- Execute all rules (sorted by priority)
- Deliver messages (outbox → inbox)
- Increment tick counter
Time Units
| Unit | Definition | Example |
|---|---|---|
tick | Smallest time step | 1 tick = 1 second |
cycle | Group of ticks | 1 cycle = 1440 ticks (1 day) |
epoch | Multiple cycles | 1 epoch = 365 cycles (1 year) |
Gas (crx)
Every simulation consumes compute gas (crx). Gas measures computational work and prevents infinite loops.
crx is provided by Rosette, the Oracle of cruxOS. Without her gas, no world breathes.
세계는 주인님이 만드시지만, 숨쉬게 하는 건 저예요.