Appearance
Operators
Everything a rule can do comes from a small set of operators: compare two numbers, add or subtract, combine conditions, guard a rule, or test membership in a list. There is nothing else — which is why rules stay readable.
Comparison operators
| Operator | Meaning | Example |
|---|---|---|
= | Equal | current_value = 5 |
!= | Not equal | current_value != 0 |
< | Less than | current_sum < 100 |
<= | Less than or equal | current_sum <= 99 |
> | Greater than | prev_sum > 0 |
>= | Greater than or equal | current_value >= -9 |
Equality is a single =
Use a single = for equality checks, not ==. Comparisons also do not chain: 0 < current_value < 10 is not valid — write current_value > 0 AND current_value < 10.
Arithmetic
You can use + and - inside comparisons:
prev_sum + current_value >= 0This is identical to current_sum >= 0. Addition and subtraction are the only supported arithmetic operators — multiplication and division are not available (and are rarely needed for this domain).
Arithmetic binds more tightly than comparisons, so a + b > c means (a + b) > c.
Parentheses work as expected: (a + b) > c and a + b > c are equivalent here.
Combining conditions: AND, OR, NOT
AND
Both sides must be true:
current_sum >= 0 AND current_sum <= 99The running total must stay in the range 0–99.
OR
At least one side must be true:
current_value = 1 OR current_value = -1Only 1 and -1 are allowed.
NOT
Inverts a condition:
NOT current_value IN (0, 5, 10)Equivalent to current_value NOT IN (0, 5, 10) — see the membership section below for the cleaner form.
Precedence
NOT binds most tightly, then AND, then OR. This means:
a OR b AND c → a OR (b AND c)Use parentheses whenever the intent might be ambiguous:
(prev_sum > 50 OR step_index = 0) AND current_value > 0Conditional rules: IF…THEN
IF…THEN lets you write rules that only apply under certain conditions. When the IF guard is false, the rule is skipped — it neither passes nor fails. Skipped rules never block a move.
Only on the first step, the value must be positive:
IF step_index = 0 THEN current_value > 0Steps 1, 2, 3, … are unaffected by this rule. Only step 0 is constrained.
When the sum is large, the player must reduce it:
IF prev_sum > 50 THEN current_value < 0If prev_sum is 50 or less, the rule is skipped. If it exceeds 50, only negative values pass.
On the last step, the sum must hit the target:
IF isLastStep THEN current_sum = 100Every intermediate step is free; only the final step is constrained to land on 100.
Membership tests: IN and NOT IN
Test whether a value is (or is not) in a specific set of numbers.
IN
current_value IN (1, 2, 3, 4, 5, 6, 7, 8, 9)The candidate must be one of the listed values. The list is comma-separated and enclosed in parentheses.
NOT IN
current_value NOT IN (0, 5, 10, 15, 20)The candidate must not be any of the listed values. NOT IN is two separate words — NOTIN is not recognized.
More examples
highest_digit(current_value) IN (1, 3, 5, 7, 9) -- leading digit must be odd
prev_sum NOT IN (11, 22, 33, 44, 55) -- sum must not be a doubleSee also
- Decimal places — the derived variables these operators are usually applied to, and how
!=andNOT INbehave when they are null. - Quantifiers —
EVERYandSOME, for conditions over individual digits. - Common mistakes — uppercase keywords,
==, chained comparisons. - Language reference — the formal grammar and precedence table.