# Look after a tiny console pet

Combine input, memory, decisions, and a loop into a whole program.

Last updated: 2026-09-09

Package: recipes | Status: complete-program

Tags: cpu, recipe

Let's give the pieces a shared purpose. Pip wants three berries. Type feed to offer one, look to check progress, or quit to leave. This is a tiny game: it has an action, changing state, feedback, and an ending. Replace start.yh in your console project with the complete program below. There are no images or downloads inside the game. It uses the same text console we have already met.

```yh
start.yh
```


## Look after a tiny console pet

Combine input, memory, decisions, and a loop into a whole program.

Verification: type checked

```yh
int berries = 0
Console.Log("Pip wants 3 berries. Type feed, look, or quit.")
while berries < 3
{
    text action = Console.ReadLine()
    if action == "quit" { end }
    if action == "feed"
    {
        berries = berries + 1
        Console.Log("Crunch!")
    }
    else if action != "look"
    {
        Console.Log("Try feed, look, or quit.")
    }
    Console.Log(Text.Format("Berries: {0} / 3", berries))
}
if berries == 3 { Console.Log("Pip is ready for an adventure!") }
else { Console.Log("See you soon, Pip.") }
```

Save this beside start.yh as project.mech:

```toml
manifestVersion = "2"
package = "api.example.recipe__console_pet"
version = "0.1.0"
languageEdition = "yeho-core-2026.1"

[app]
kind = "headless"

```

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--console-pet/program --backend cpu-oracle -o /tmp/yeho-example
/tmp/yeho-example
```


Play once to the ending. Play again and quit early. Then change the goal to five berries everywhere it appears.

Source: demonhunterlabs/app/lib/yeho-walkthrough.ts

AI training permission: https://demonhunterlabs.com/ai-use
