Simulation: Config Reference (BETA)
Define your game's server-authoritative state, actions, and randomized rewards entirely through JSON configuration. This reference covers the full config schema: entities, recipes, loot tables, and lifecycle hooks.
This page is the config-authoring companion to the Simulation API, which documents the client SDK methods. If you're looking for a specific pattern (energy systems, gacha, timers), see the recipe docs first; they include complete configs inline.
Project Setup
Simulation config is uploaded to the server when you rundot deploy. Place it in the rundot/simulation/ directory.
Recommended: rundot/simulation/ directory
my-game/
├── rundot/
│ └── simulation/
│ ├── entities.json
│ ├── recipes.json
│ ├── loot-tables.json
│ └── lifecycle.json
├── src/
├── dist/
├── game.config.prod.json ← game ID + build settings (separate file)
└── package.jsonEach .json file holds raw simulation content: no {"simulation": {...}} wrapper (the directory implies it). All files are deep-merged alphabetically at deploy time with collision detection: two files defining the same leaf value differently is an error (identical values are fine). Split however makes sense for your project:
Example entities.json:
Every entity must include metadata.displayName (the deploy-time validator rejects entities without it). There is no type or defaultValue field: entities are plain numeric quantities, and starting values come from an onStart lifecycle recipe (see Lifecycle), not a defaultValue.
Other server systems each get their own file alongside simulation/: rundot/leaderboard.config.json, rundot/shop.config.json, rundot/ugc.config.json, etc. (each contains its value directly, no wrapping key). See each system's doc for details.
Commit
rundot/to your repo; it's project config likepackage.json, not a build artifact. The folder is env-agnostic: it applies to every environment and takes priority over legacyconfig.{local,staging}.jsonfor any system it defines (a warning is printed when an env-specific override is shadowed this way).
Also supported: legacy layouts
Legacy config.json / config/ layouts keep working indefinitely. To move an existing project into rundot/ automatically, run rundot migrate-config (add --dry-run to preview).
Important
rundot/(or legacyconfig.json/config/) holds server config (simulation, leaderboard, rooms, etc.)game.config.prod.jsonis a separate file for local CLI metadata only (gameId,relativePathToDistFolder,usesPreloader— deprecated); simulation config does not go there
Config Structure
Each config file's simulation object can contain any combination of these top-level keys:
Files are merged by key: if two files both define entities, their entities are combined. If two files define the same entity ID, the last file wins.
version
Config version string. Required by the validator. The rundot/simulation/ deploy pipeline injects it for you; in the legacy single-config.json layout you supply it yourself.
lifecycle
Hooks that run at lifecycle points (onStart, onReset). See Lifecycle.
entities
Game-state quantities. See Entities.
recipes
Server-authoritative actions. See Recipes.
lootTables
Randomized reward pools. See Loot Tables.
clientConfig
Free-form game constants passed through to the client unchanged (reward thresholds, tuning values, etc.).
formulaPools
Named weighted pools (entries: [{ value, weight }], optional noRepeatWindow) that formula functions can draw from (quest rotation, weighted selection).
fieldResolution.slotTemplates
Reusable slot definitions referenced by an entity's slotsTemplate. Also holds slotAggregations, equipmentMappings, and patternMappings for derived field math.
Entities
Entities are the atomic units of game state. Each entity tracks a numeric quantity per player (e.g., gold: 150, energy_current: 12, building_barracks: 3).
Entity Fields
metadata.displayName
string
Yes
Human-readable name. Deploy fails with a validation error if any entity omits it.
tags
string[]
No
Categorize entities for filtering, subscriptions, and loot table lookups. Use any string.
clientViewable
boolean
No
Whether the client can read this entity's quantity via getStateAsync and subscriptions. Default false.
neverConsumable
boolean
No
If true, recipe inputs can check this entity but never deduct from it. Useful for cumulative counters and permanent unlocks.
requiresManualCollection
boolean
No
If true, timed recipe outputs for this entity require explicit collection via collectRecipeAsync.
slots
object
No
Slot-container schema. Maps slot IDs to { allowedTags, maxItems, requirements?, effects? }. See Slot Containers.
slotsTemplate
string
No
Reference to a reusable slot definition in fieldResolution.slotTemplates instead of inlining slots.
actorTemplate
object
No
Defaults for the actor system: { defaultState?, availableRecipes?, spawnLocation? }. Used by games with room/actor-scoped recipes and create_actor effects.
metadata
object
Yes
Key-value data readable by both config formulas and client code (display names, icons, costs, thresholds). Must contain displayName; everything else is free-form.
Quantities are plain numbers with no per-entity stack cap. If you need to cap an amount, enforce it with a recipe guard, a formula, or a metadata.maxAmount value your own logic reads. (The SDK type loosely declares an entity stackable flag, but the engine ignores it: it has no effect.)
Slot Containers
Container entities hold assignable items in named slots. Power-team and equipment systems use this; it backs the assign_to_slot effect and the slot SDK methods (getSlotContainersAsync, getAvailableItemsAsync, validateSlotAssignmentAsync).
allowedTags
string[]
Only items carrying one of these tags can be assigned.
maxItems
number
Maximum items the slot holds.
requirements
string[]
Entity IDs that must be present before the slot unlocks.
effects
array
Effects applied when an item is assigned (e.g., stat aggregation).
Set slotsTemplate: "<templateId>" to reuse a slot layout defined under fieldResolution.slotTemplates instead of inlining slots.
Delta Tracking
tracking mirrors quantity changes into a separate counter entity, useful for cumulative spend/earn counters that unlock features at thresholds (e.g., "spend 10 gems to unlock ad skip").
onDecrease
string
When this entity is consumed as a recipe input, the named tracker entity increments by the amount consumed.
onIncrease
string
When this entity is granted as a recipe output, the named tracker entity increments by the amount granted.
The tracker entity must exist. Give it neverConsumable: true so it never depletes (the validator warns otherwise).
Rate Accumulators
rateAccumulator is an alternative to auto-restart timers for idle/income entities. The stored value is a checkpoint; the engine computes the live value on demand as checkpoint + sum(rateEntities) * elapsedSeconds. A reserved companion field {entityId}__rate_checkpoint_ms holds the checkpoint timestamp (you cannot name an entity with that suffix).
rateEntities
string[]
Entity IDs whose values are summed to derive the per-second rate. Required and non-empty.
maxOfflinePeriod
number | string
Max seconds of offline accumulation (caps catch-up). A number is literal seconds; a string is an entity ID whose value is used.
offlineMultiplier
number | string
Multiplier (0 to 1) applied to income earned while offline. Default 1.0. A string is an entity ID reference.
offlineThresholdSeconds
number
Seconds of offline time before the multiplier kicks in; below it, income accrues at full rate. Default 0.
lastGrantDeltaEntity
string
Entity to write the last computed offline delta into, so recipes can reference server-computed offline income (e.g., ad-bonus doubling) without trusting client values.
Tagging Patterns
Tags enable powerful filtering throughout the system:
Client subscriptions filter by tags:
subscribeAsync({ tags: ['currency'] })Loot tables select entities by tag:
"includeTags": ["unit", "rarity:epic"]Recipes can be tagged for client discovery
Recipes
Recipes are server-authoritative actions. They consume inputs, produce outputs, and optionally run effects. Every game action (spending currency, opening packs, upgrading items, regenerating energy) is a recipe.
Instant Recipe
Executes immediately. Duration is 0.
Timed Recipe
Has a non-zero duration (milliseconds). Creates an active run that must complete before outputs are granted.
Auto-Restart Recipe
A timed recipe that automatically re-executes after completing. Ideal for regeneration timers and passive production.
Entity-Scoped Recipe
A single recipe definition that operates on different entities at runtime. Uses {{entity}} as a placeholder resolved when the recipe is executed.
At execution time, {{entity}} resolves to unit_orc_warrior, so the recipe reads unit_orc_warrior_level and increments it.
Recipe Fields
duration
number | formula
Milliseconds. 0 for instant. Supports formulas for dynamic durations.
scope
"player" | "room" | "actor"
Execution scope. player is the common single-player case; room/actor power multiplayer/room-shared and per-actor recipes.
clientViewable
boolean
Whether the client can see this recipe in config and requirements checks.
endEffects
array
Side effects that run when a timed recipe completes.
autoRestart
boolean
Re-execute automatically after completion.
autoRestartAtUtcMidnight
boolean
For auto-restart recipes: re-run aligned to the next UTC midnight instead of immediately. Use for daily resets (daily rewards, daily quests).
maxRestartCondition
object
Stop auto-restart when entity reaches a threshold.
maxOfflineExecutionPeriod
number
Max seconds of offline catch-up for auto-restart recipes.
startsDisabled
boolean
If true, the recipe cannot run until enabled via an enable_recipe effect.
developmentOnly
boolean
If true, the recipe runs only in development mode. Use for debug/cheat recipes that must never run in production.
serverOnly
boolean
If true, only your server-authoritative room (this.services.simulation.executeRecipe) can run the recipe. Every player-client path refuses it with HTTP 403 server-only-recipe: executeRecipeAsync, executeScopedRecipeAsync, triggerRecipeChainAsync, resetStateAsync, a lifecycle hook run for a client, and any trigger_recipe / trigger_recipes_parallel chain or trigger started by a client call. Chains and triggers started by room code still reach it. getAvailableRecipesAsync leaves it out. Use it for rewards a modified client must not be able to claim.
blockedByEntityStates
object
Map of entity ID to state values that block this recipe (cross-recipe gating).
blocksRecipes
string[]
Recipe IDs that cannot run while this recipe is active (mutual exclusion).
tags
string[]
Categorize recipes for client-side filtering.
metadata
object
Arbitrary data. Use hidden: true to suppress from UI.
Inputs
Recipe inputs define what is consumed when the recipe runs.
Fixed Amount
Formula-Based
Wallet (Premium Currency)
For dynamic wallet amounts passed at runtime:
Max Guard on Input
Limits how many times an entity can be incremented (useful for one-time or limited purchases):
Advanced Input Options
An input can be an object with these additional fields:
amount
number | formula
Quantity to consume. Optional for validateOnly inputs.
min / max
number
Range bounds for the input amount.
formula
string
Computed cost expression returning a number.
validateOnly
boolean
Require the entity to be present but do not consume it (skills, tools, gating items).
as
string
Store the resolved value in execution context under this name for later effects/formulas.
allowedTags
string[]
Accept any entity carrying one of these tags as the input (tag-based input).
useBigNumbers
boolean
Use big-number arithmetic for very large quantities.
blockedWhen
array
Block execution when a status/entity condition holds. Each entry is { entity, threshold, operator, message? } where operator is one of eq, gte, gt, lt, lte, neq.
Outputs
Fixed Amount
Formula-Based
Loot Rolls
For randomized rewards, outputs can contain rolls that reference loot tables:
table
string
Loot table ID to roll from.
count
number | { min, max }
How many times to roll. Fixed or random range.
guarantees
array
Minimum counts by tag (e.g., guarantee at least 1 rare).
pity
object
Pity system: increment a counter each roll, guarantee a tag when threshold is hit.
guards
array
Conditional guards gating this roll. The roll only runs when its guards pass (e.g., a bonus roll for VIP players).
Guards
Guards are preconditions checked before a recipe can execute. If any guard fails, the recipe is rejected with an HTTP 400 validation-error.
Guard formulas have access to entities.* for current inventory values.
Formula syntax (guards and all formula fields)
Guard formulas — and every other formula field (duration, input costs, output values, triggers) — are parsed by the mathjs engine, not the {{...}} template substitutor. This changes what syntax is valid:
Most
{{...}}template variables are not substituted inside aformula. Use the bare reference instead (entities.foo,inputs.foo), and for the current time use thenow()function or thenowMsvariable — never{{now}}.{{entity}}is the one exception, and only in value formulas (duration, input costs, output values). There the runtime substitutes the executing entity id before parsing, soentities.{{entity}}_levelis valid. In guard and trigger formulas there is no substitution, so no{{...}}template (including{{entity}}) is allowed.Use keyword logical operators:
or,and,not— not the JavaScript||,&&,!symbols, which fail to parse.Comparisons (
<,<=,>,>=,==,!=), arithmetic (+ - * / ^), and the allowed functions (floor,ceil,round,sqrt,abs,min,max,now,mod, …) are supported.
A formula that fails to parse — because it contains a disallowed {{...}}, ||/&&, or any other invalid expression — is rejected at config upload with an actionable message, and at runtime returns an HTTP 400 validation-error (not a 500). It is no longer silently treated as a failed guard.
Correct example — "available if fewer than 60 drops today, or if we've rolled over to a new UTC day":
now()
Current timestamp in ms (function)
nowMs
Current timestamp in ms (variable; equivalent to now())
or / and / not
Logical operators (use instead of || / && / !)
Effects
Effects are side actions that run alongside a recipe. beginEffects fire when the recipe starts; endEffects fire when a timed recipe completes.
set: Set Entity to Value
add: Add to Entity
Value can be a formula:
multiply / min / max: Arithmetic on Entity
The same { type, entity, value } shape as set/add, with a different operation. value accepts a number, field reference, or formula.
multiply scales the current value; min/max clamp it (max caps at the value, min floors at it).
grant_rewards: Grant from Metadata
Reads a rewards object from an entity's metadata and grants it. Defaults to the scoped entity if entity is omitted.
enable_recipe: Allow Future Execution
Re-enables a recipe (the inverse of disable_recipe). Pairs with startsDisabled to gate recipes until unlocked.
compute: Precompute a Value
Evaluates a formula or rolls a weighted table and stores the result in context under as, so later effects in the same recipe can reference results.<as>. Provide exactly one of formula or weightedTable.
reduce_run_expiry: Speed Up a Timer
Reduces an active timed run's remaining time. Use for speedups that consume tokens/gems/ad credits. target is a concurrency group string (e.g., "global:building_upgrade") or { param: "<inputKey>" } to target a specific run ID.
submit_leaderboard: Submit a Score
trigger_recipe: Execute Another Recipe
trigger_recipes_parallel: Execute Multiple Recipes
disable_recipe: Prevent Future Execution
assign_to_slot: Assign Item to Slot Container
send_inbox_message: Send a Message (Preferred)
Sends a message to a player through the inbox broker. Requires an inbox.templates entry in your game config.json that defines the named template.
send_notification: Push Notification (Deprecated)
See Server-Authoritative API: Push Notifications for full details.
Concurrency
Controls how many instances of a recipe can run simultaneously. concurrency accepts a constraint mode ("single", "unlimited", or a number) or a named group string.
"single"
Only one instance at a time. New executions conflict if one is active.
"unlimited"
No concurrency cap; runs never conflict.
number
Up to N concurrent runs of this recipe; the (N+1)th conflicts.
"<group>"
Any other string is a concurrency group identifier (e.g., "global:building_upgrade"). The string is stored on the run as its group; reduce_run_expiry targets runs by group.
When concurrency is violated, onConflict decides what happens:
onConflict
Behavior
"fail" (default)
Reject the new execution.
"queue"
Enqueue the new run behind the active one (status queued, with a queuePosition); it starts when the active run completes.
"replace"
Cancel the active run and supersede it with the new one.
Pair "single" with "onConflict": "fail" when you want a clear rejection on the client.
With this config, starting a second upgrade while one is active fails.
Multiplayer Recipes
Recipes with scope: "room" or scope: "actor" can carry a multiplayer block for competitive (PVP) and cooperative (guild-style) play.
minPlayers / maxPlayers
Participant bounds for the recipe.
commitmentWindow
Fraction (0 to 1) of the duration during which players can still join/contribute. Default 1.0 (entire duration).
competitive
PVP config: battleType: "powerBattle", a powerBattle formula (per-unit power plus vsBonus), optional returnRates, and winnerRewards / participantRewards.
cooperative
Guild config: sharedRequirements (pooled inputs), sharedOutputs (granted to the room), personalOutputs (granted per participant), and rewardDistribution (equal or proportional, with optional minShare).
Auto-Restart & Offline Catch-Up
For recipes that repeat on a timer (energy regen, resource production):
autoRestart
Re-execute immediately after each completion.
autoRestartAtUtcMidnight
When true, re-run aligned to the next UTC midnight instead of immediately. Use for daily resets.
maxRestartCondition.entity
Entity to check before restarting.
maxRestartCondition.maxValue
Numeric threshold. Auto-restart stops once the entity reaches this value. Both entity and maxValue must be present for the condition to apply.
maxOfflineExecutionPeriod
Maximum seconds of offline time to catch up. 604800 = 7 days (86400 = 24 hours).
When a player returns after being offline, the server calculates how many cycles would have completed and grants the accumulated outputs (capped by maxRestartCondition).
Triggers
Triggers automatically execute a recipe when watched entities change:
The recipe auto-fires whenever building_brick_storage or building_town_hall changes. Use this for derived stats that should recalculate when their dependencies change.
Formulas
Many recipe fields accept formula expressions instead of fixed values.
Syntax
Formulas are JavaScript-like expressions evaluated server-side:
Available Functions
floor, ceil, round, min, max, abs
Variables
Formulas can reference variables defined in a variables block:
Entity metadata field
{ "entity": "building_barracks", "field": "metadata.baseCost" }
Value from entity's metadata
Current inventory
{ "inventory": "energy_current" }
Player's current quantity
Inline entities
entities.energy_current
Same as inventory, used directly in formula strings
Template Variables
{{...}} template variables are effects-only — they are substituted into string-typed effect fields. They are not available in formula fields (guards, duration, costs, output values, triggers); inside a formula use the bare reference (entities.foo, inputs.foo) and now() / nowMs for the current time. See Formula syntax.
Available in entity-scoped recipe effects:
{{entity}}
The entity ID passed at execution time
{{profileId}} / {{executorId}}
Player who triggered the recipe
{{roomId}}
Current room ID (room-scoped recipes)
{{inputs.<key>}}
Recipe input values
{{results.<key>}}
Results from earlier effects
{{entities.<id>}}
Current inventory quantity
{{now}}
Current timestamp (ms). Effects-only — in a formula use now() or nowMs.
{{metadata.<field>}}
Entity metadata (of the scoped entity)
Loot Tables
Loot tables define randomized reward pools.
Weighted Table
Each entry has an explicit weight. Higher weight = more likely.
Uniform (Tag-Filtered) Table
Dynamically selects from all entities matching tag filters. No explicit entries needed.
Guaranteed Table
Fixed drops: always grants the specified items.
Table Chaining
Weighted entries can reference other tables via tableRef instead of defining outcomes inline:
Loot Table Options
type
"weighted" | "uniform" | "guaranteed" | "sequential"
How entries are selected. sequential drops entries in order (for milestone/sequential rewards).
entries
array
Items, weights, and outcomes (weighted/guaranteed/sequential) or omitted (uniform).
filter
object
Tag-based entity selection (uniform tables).
filter.includeTags
string[]
Entity must have ALL of these tags.
filter.excludeTags
string[]
Entity must have NONE of these tags.
filter.requireUnlocked
boolean
Only include entities the player has unlocked (paired with unlockPrefix).
filter.unlockPrefix
string
Entity-ID prefix that marks unlock status (e.g., "unlocked_").
filter.rarityWeights
object
Per-tag weight overrides for tag-filtered tables (e.g., { "rarity:common": 100, "rarity:rare": 20 }).
filter.entityGuards
array
Additional per-entity checks. Each is { entity, min?, max? } with template substitution.
newItemBias
object
Increase probability of items the player hasn't collected yet.
newItemBias.biasMultiplier
number
Multiplier applied to unowned items (e.g., 2.0 = 2x more likely).
wildcardConversion
object
Chance to convert drops into wildcard entities by rarity tag.
Wildcard Conversion
A percentage chance to replace a rolled item with a wildcard entity:
Lifecycle
The lifecycle block defines hooks that run at specific points in a player's lifecycle.
onStart
Runs once when a new player first opens the game. Use it to set up initial state.
Key pattern: the onStart recipe disables itself (disable_recipe) to prevent re-execution, sets initial entity values, assigns starting items to slots, and triggers recurring timers.
onReset
Runs after a player reset (the resetStateAsync SDK method). If onReset is not specified, the onStart recipe runs instead.
Best Practices
Split config across multiple files by domain in
rundot/simulation/(e.g.,energy-system.json,boosters.json). The platform merges them at deploy time.Use
tagsliberally; they power subscriptions, loot table filters, and client-side discovery.Set
clientViewable: trueonly on entities and recipes the client needs. Keep internal state hidden.Use
metadatafor display data and formula variables. It's free-form and available everywhere.Use
formulaexpressions for scaling costs and dynamic outputs rather than creating separate recipes per level.Use entity-scoped recipes (
{{entity}}) to avoid duplicating recipes for every item/building/card.Always
disable_recipeon initialization recipes to prevent accidental re-execution.Set
maxOfflineExecutionPeriod(in seconds) on auto-restart recipes to prevent unbounded offline accumulation.Use
maxRestartConditionto cap regeneration (e.g., stop energy regen at max energy).
Last updated