Registers

6 min read

Tip

The Register button in the toolbarThe Register button in the toolbarRegisters (R) can alter the state of Nodes or influence the flow of Resources based on the computation of multiple inputs coming from either Nodes in the diagram or your own input during a diagram Step-by-Step Run.

Properties

Select a Register to adjust it in the Properties panel on the right: its label and note, Trigger, Formula, Limits, and the switches Lever and Outcome. Color and text style are on the floating toolbar that appears above a selected node.

Register properties panel: Behavior summary, the Lever and Outcome switches, Trigger buttons Auto, Passive and On click, a Formula box and Limits with min and max.Register properties panel: Behavior summary, the Lever and Outcome switches, Trigger buttons Auto, Passive and On click, a Formula box and Limits with min and max.
Register properties. The panel shows the extra hint under the Formula box once the Register has an input.

Label

Click Add a label to name what the Register represents in your model, for example Sum of XP Points. The Formula box holds the calculation; Limits keep the value between a minimum and a maximum; Lever lets a scenario change the value.

Example Register: Sum of XP PointsFields transcribed from the published 2021 screenshot. The names and formula are an example, not a live app state.
LabelSum of XP Points
Formulaa + b
The Formula box of a Register, here containing the number 3.The Formula box of a Register, here containing the number 3.
The Formula box

A Register has three Trigger choices: Auto, Passive and On click. It has no Agentic or On enable button. A Register that is On click is what earlier guides call interactive: you change its value by hand during a Play, and it takes only State Connections, in and out.

Register properties panel with the On click Trigger selected, showing a Value section with an initial value of 0 and an increment of 1, and Limits min and max.Register properties panel with the On click Trigger selected, showing a Value section with an initial value of 0 and an increment of 1, and Limits min and max.
An On click Register: Value initial 0 and increment 1

By default, Registers are passive.

Passive Registers

Passive Registers may gather input from multiple origin Nodes, compute them based on formulas, and influence the state of other Connections or Nodes within the diagram.

Each Register input State Connection is assigned a letter Formula. Use these identifiers as variables in the formula the Register needs to compute.

Before Play, a passive Register displays fx. During Play, it displays the computed result.

Passive Registers Properties

For passive Registers the Formula is used to input the function you want it to compute.

Published formula example: a + b.

The Formula box of a Register, here containing the number 3.The Formula box of a Register, here containing the number 3.
Formula-field screenshot
Note

The Formula field for Registers supports functions from the math.js library. You can find out more about them in the Math.js Functions article.

Every formula box has a Formula builder button (sparkle). Use it to search functions, insert a component’s value or a parameter, and ask AI to suggest a formula.

Example Register limitsValues transcribed from the published 2021 screenshot; the separate Coins example below uses a different minimum.
Minimum

3

Maximum

100

The Limits fields of a Register, with min and max boxes.The Limits fields of a Register, with min and max boxes.
Limit-fields screenshot

You can set a minimum and maximum value for a Register, which can further affect its value.

For example: If the flow of producing Coins in a game is influenced by several factors (inputted to a Register), and you’ve set the minimum limit of that Register to 10, no matter how the inputs evolve throughout a play session, the player will, by the end of it, have at least 10 Coins.

Interactive Registers

A Register becomes interactive when its Trigger is set to On click in the Properties panel. The Register is then drawn as a raised key with two inner buttons: press them during a Play to change its value, and hold a button to repeat.

Please note that an On click Register fires only when you click it during a Play, and never in a Forecast.

Interactive Registers Properties

Warning

Interactive Registers do NOT support formulas!

Use a minimum and/or a maximum value under and/or over which the Register doesn’t allow changes.

Interactive Register with limitsSettings used in the recording below, shown in the Properties panel.
Allowed range
Minimum3
Maximum5
Interactive value
Initial3
Increment2

An On click Register has a Value section with two boxes:

  • Initial – sets the value the Register passes on upon starting a Play. A new Register starts at 0.
  • Increment – sets how much the value changes with each click on the Register. A new Register has an increment of 1.

In the published example, the interactive Register starts at 3 and uses an adjustment step of 2. Each user adjustment changes its value by plus or minus 2 during Play.

The Value section of an On click Register with an initial value of 0 and an increment of 1.The Value section of an On click Register with an initial value of 0 and an increment of 1.

Outcome and Lever

The Lever and Outcome switches in the Register properties panel.The Lever and Outcome switches in the Register properties panel.

The Outcome switch, at the top of the panel under the Behavior summary, plots the Register’s values over the Play steps, and it is on by default. The Lever switch lets a scenario change the Register's value.

Multiplying Target Value

Register settings in the target exampleThe model above explains how the target value is multiplied.
Initial value

5

Increment

5

The Value boxes of a Register with an initial value of 5 and an increment of 5.The Value boxes of a Register with an initial value of 5 and an increment of 5.
Target-example Register screenshot

In the example above we are multiplying the Target value. To obtain this, we used an On click Register with an Increment equal to the Target’s value. In order to have an integer x multiplying factor, we used “+100%” as a Formula on the State Connection.

This results in the Target being multiplied by the number of Steps that the user interactively changes on the Register during execution.

Note: for those looking for the deprecated m operator, this method generates the same effect. If you need to multiply functions on the Target, then the Origin needs to be a passive Register with a formula identical to that of the Target.

Using math.js functions

Basic Calculations

  1. add(a,b) adds the values of a and b
  2. subtract(a,b) subtracts b from a
  3. multiply(a,b) multiplies the values of a and b
  4. divide(a,b) divides a by the value of b

Exponential Functions

  1. square(a) returns the square value of a (a*a)
  2. cube(a) returns the cubic value of a (a*a*a)
  3. sqrt(a) returns the square root of a
  4. cbrt(a) returns the cubic root of a
  5. pow(a,b) returns the value of a raised to the power of b

OR / AND Register

In the example below, we’re using Registers to keep track of certain value occurrences.

On the left, a random number of Resources (D6 – between 1 and 6) are being produced and stored in the Pools. In each Step, the Register checks if the number of Resources stored in either of the two Pools is higher than 2, sums the values up, and activates the Source to its right if the sum is >0.

On the right, we use the same model to count when the Pools simultaneously contain a number of Resources above 2. The formula on the Register uses multiplication instead of addition to achieve this.

The Sinks have the role of resetting the Pools values.

If Statements

If you’re trying to model complex if statements, you can use Registers to calculate conditions. You can find an example for both context and solution, in the article on how to emulate the Artificial Player legacy component, with machinations.io Nodes and Connections.

Other math.js functions

For more examples on using math.js functions with Registers, try out the public diagram below.

Example: Level Progression

This model represents a simplistic leveling-up system.

  1. The Register “Gained XP” computes XP received by the player based on Enemies killed and XP per kill.
  2. The Register “Level up cost” computes the cost of leveling up based on player Level and a “variable” that you can manually tweak during Play by clicking on the arrows of the Register (starting value: 100)

Selected models to Play and remix: Selected reward system models, Selected feedback loop models.