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, Assets, Player Types, Players, and other definitions available in the current context. Function Parameters appear only while editing the Function Body that declares them. They are that Function's inputs, not reusable game Variables; a caller supplies their values as arguments to the Function. Use Add Variable (+) in the Variables group to define a reusable value without leaving the current formula. After its name, type, scope, and calculation point are defined, the new Variable is inserted at the current cursor position. Choose whether to define a formula or only create a stored value. The new formula editor opens with its current contents selected, so typing can replace the initial expression immediately. Market initialization formulas restrict creation to Variables calculated at game start.
- Functions opens the function catalog grouped by purpose.
- Patterns lists common calculations that fit the expected result type and the Variables, Choices, or Function Parameters available in the current editing context.
- 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.
Selecting a Pattern asks for each required input and replaces the editor text with an ordinary formula. You can immediately change any part of it. The initial catalog contains conditional value, total, average, minimum, maximum, difference, and ratio. A Pattern is omitted when the current definition has no compatible input, such as a numeric collection for Total.
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
Pattern offers start collapsed so their names and descriptions can be scanned quickly. Open one offer to select its inputs and use it. Applying a Pattern inserts an ordinary formula that can still be edited directly; function identifiers remain in the formula language regardless of interface language.
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.