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.
- Definition opens a searchable picker for Variables, Choices, Player Types, Players, Assets, and other definitions available in the current context.
- Functions opens the function catalog grouped by purpose.
- the main text area accepts a formula directly,
- validation below the editor reports whether the expression is valid,
- Apply stores the expression in the current draft,
- Cancel leaves the previous expression unchanged.
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:
- Participants: participant counts, usernames, identifiers, Player Types, and groups.
- Runtime: round, time, automatic response, phase, matrix selection, iteration, and collection across participants.
- Runtime updates: game duration, player activity/type, and Stage transition updates.
- Math: numeric functions and aggregates.
- Collections: size, transpose, merge, sorting, selection, decomposition, and weighted selection.
- Text: text predicates.
- Random: uniform, normal, bounded, count, beta, piecewise, and triangular distributions.
- Market: cash and endowment queries or updates.
- Market event: current transaction Asset, valuation, profit, price, quantity, side, and time.
- Market updates: Buy/Sell permission changes.
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.