Formula Editor Reference

The Formula editor creates typed expressions used by Variables, Choices, conditions, payoffs, routes, timing, and Market outputs.

Editor Structure

The heading identifies the value being defined. Context labels show the expected result type and, where available, preview status and referenced elements.

Picker insertion uses stable definition references. Names containing spaces are formatted with backticks.

Types And Empty Values

The destination supplies an expected type such as number, integer, boolean, text, or any. The editor rejects expressions whose result is incompatible with that destination.

An empty or missing value is not numeric zero and is not automatically false. Use explicit conditions when missing data has a distinct meaning.

Function Groups

The current catalog is organized into:

The Functions picker shows each signature and its short description. Functions remain context-sensitive: a Market event function has meaning only while evaluating a Market event output.

Common Formula Patterns

Initial random value

Use a random distribution in a Variable calculated At game start, for example:

Uniform(0, 100)

Conditional value

Use if(condition, when_true, when_false) when one value depends on a Choice or state:

if(choice::\Accept offer\ = "Accept", variable::\Current offer\, 0)

Accumulator

In a Stage or transaction output, refer to the previous Variable value and add the new contribution:

variable::\Total\ + quantity()

Collection summary

Use an aggregate such as sum(values), average(values), or median(values) when the input is a collection.

Automatic completion branch

In a Free Form route or output, distinguish timeout or automatic completion with:

automatic_response()

References And Renaming

References identify definitions by stable ID even though the formula displays readable names. Renaming a Variable, Choice, Player Type, Player, or Asset does not require manually rewriting every attached reference.

Use the Definition picker when possible. Manually typed names must resolve uniquely in the current formula context.

Validation And Preview

Validation checks syntax, reference resolution, argument types, and expected result type. A formula can be syntactically valid but still be unavailable at runtime if it reads a value before its lifecycle source has run.

Preview availability depends on context and current sample state. It is assistance, not a substitute for Validation and a test run.