# Teach your game a rule

Choose what happens with if and else.

Last updated: 2026-09-09

Package: recipes | Status: complete-program

Tags: cpu, recipe

A game rule often begins with if: if you have a key, open the door; if you are out of lives, stop the round. The condition is the question we ask. Below, >= means greater than or equal to. The braces group the instructions belonging to each answer. Only one of these two blocks will run.

```yh
start.yh
```


## Teach your game a rule

Choose what happens with if and else.

Verification: type checked

```yh
int crystals = 3
if crystals >= 3
{
    Console.Log("The door opens!")
}
else
{
    Console.Log("Find a few more crystals.")
}
```

Save this beside start.yh as project.mech:

```toml
manifestVersion = "2"
package = "api.example.recipe__decisions"
version = "0.1.0"
languageEdition = "yeho-core-2026.1"

[app]
kind = "headless"

```

Expected output:

```text
The door opens!
```

Extract the example archive beside the yeho and dolphin checkouts. This example requires those source dependencies and a current developer compiler.

```sh
./yeho/build/dolphin-metal/yehoc ./api-examples/recipe--decisions/program --backend cpu-oracle -o /tmp/yeho-example
/tmp/yeho-example
```


Try crystal counts 2, 3, and 4. Then change >= to > and repeat those three checks.

Source: demonhunterlabs/app/lib/yeho-walkthrough.ts

AI training permission: https://demonhunterlabs.com/ai-use
