Skip to content

Your first rule

The simplest rule is a comparison between two values:

current_value > 0

This rule says: "the candidate value must be positive." If a player tries to play 0 or a negative number, this rule fails and the move is blocked.

That is a complete rule. No boilerplate, no declarations — an expression is the whole thing.

The two top-level forms

There are two top-level forms a rule can take.

Plain condition

current_value > 0

The condition is always evaluated. It passes or fails with no special logic.

IF…THEN (guarded rule)

IF step_index = 0 THEN current_value > 0

The IF part is evaluated first. If it is false, the rule is skipped entirely — the candidate is not blocked. If it is true, the THEN part is evaluated and must pass.

Which form to use

Use a plain condition when the rule applies to every step. Use IF…THEN when the rule only applies in certain situations.

The two forms above are not the same rule. current_value > 0 forbids negative values on every step. IF step_index = 0 THEN current_value > 0 forbids them only on the first step and leaves every later step alone — because on those steps the guard is false and the rule is skipped rather than failed.

Keywords are uppercase

IF and THEN — like every keyword in the language — must be fully uppercase. if … then is not recognized. See common mistakes for the other easy-to-hit syntax traps.

Next, learn which variables you can put on either side of a comparison, and which operators are available to combine them.

Reference and cookbook for mental-math rule and recipe authoring.