Recipe Discovery
Recipe discovery lets players find recipes by trying things out instead of reading a list. Mixing the right ingredients, in any order, reveals a recipe, and the game remembers it for good. After several wrong tries in a row, the game points at one missing ingredient, so a stuck player keeps going.

Paste this to your AI
Copy it into Claude, Cursor or ChatGPT. It already has good values and the usual mistakes in it.
Add "Recipe Discovery" to my game.
What it should do: A recipe the player found by experimenting feels like an earned discovery, and a hint after a run of misses keeps a stuck player from giving up or opening a guide.
Build it exactly as this state machine. First check that it fits my game, then build it like this:
```mermaid
stateDiagram-v2
[*] --> blank
blank: Nothing found
hinted: Hint showing
growing: Some found
complete: All found
blank --> blank: wrong mix
blank --> hinted: hint appears
blank --> growing: first find
hinted --> hinted: still stuck
hinted --> growing: a find
hinted --> complete: last find
growing --> growing: find or wrong mix
growing --> hinted: hint appears
growing --> complete: last find
complete --> complete: nothing left
complete --> [*]
```
Use these starting values:
- hintAfter: 5
- maxIngredients: 4
Watch out for these common mistakes:
- Water then herb works, herb then water does not: Tell your AI: compare a mix as a pile. Sort the ingredients before comparing, so the order is ignored.
- Two herbs find the one-herb recipe: Tell your AI: keep repeated ingredients when comparing. Two herbs and one herb are different mixes.
- Repeating a found recipe resets the hint: Tell your AI: a mix that matches a known recipe changes nothing at all.
- A recipe that can never be found: Tell your AI: check the recipe book when the game starts. Report any recipe with more ingredients than the table takes, and any two recipes that are the same pile.
- A hint that gives the game away, or points at nothing: Tell your AI: a hint is one ingredient of a recipe that is still missing, and every find clears it.
- Found recipes vanish on loading: Tell your AI: save the list of found recipes with the game, and load it back before the first mix.
Do not change anything else in the game. Do not claim anything without proof: model what it takes, and show me what your solution rests on and how I can see that it works. If you cannot show something, say you do not know. When you are done, tell me in plain words how to try it.Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP
What it does
A recipe the player found by experimenting feels like an earned discovery, and a hint after a run of misses keeps a stuck player from giving up or opening a guide.
How it runs, as a diagram
Everything it can be in, and what moves it on. Your AI builds from exactly this.
How it runs, as a diagram
- Nothing found → Nothing found: wrong mix
- Nothing found → Hint showing: hint appears
- Nothing found → Some found: first find
- Hint showing → Hint showing: still stuck
- Hint showing → Some found: a find
- Hint showing → All found: last find
- Some found → Some found: find or wrong mix
- Some found → Hint showing: hint appears
- Some found → All found: last find
- All found → All found: nothing left
Good starting values
| Value | Start with | What it changes |
|---|---|---|
| hintAfter | 5 | How many wrong mixes in a row before the game gives a hint. Too low and the hint replaces experimenting, too high and a stuck player gives up first. |
| maxIngredients | 4 | How many ingredients one mix can hold. It must be at least as many as the biggest recipe needs, or that recipe can never be found. |
What usually goes wrong
Water then herb works, herb then water does not
The mix is compared as a list, so the same two ingredients in the other order find nothing. The player concludes the recipe is wrong and moves on.
Fix: Tell your AI: compare a mix as a pile. Sort the ingredients before comparing, so the order is ignored.
Two herbs find the one-herb recipe
Ingredients are compared as a set, which forgets repeats. Herb, herb and water then finds the tonic that wants a single herb, although the player used more than that.
Fix: Tell your AI: keep repeated ingredients when comparing. Two herbs and one herb are different mixes.
Repeating a found recipe resets the hint
The player mixes a known recipe to check something. The game treats it as a find and clears the count of wrong mixes, or as a miss and moves the hint closer. Either way the hint timing is wrong.
Fix: Tell your AI: a mix that matches a known recipe changes nothing at all.
A recipe that can never be found
A recipe needs five ingredients but the table takes four. Or two recipes use the same ingredients. The player can mix forever and never find it.
Fix: Tell your AI: check the recipe book when the game starts. Report any recipe with more ingredients than the table takes, and any two recipes that are the same pile.
A hint that gives the game away, or points at nothing
The hint shows the whole recipe, so the discovery is gone. Or it keeps pointing at a recipe the player found a minute ago.
Fix: Tell your AI: a hint is one ingredient of a recipe that is still missing, and every find clears it.
Found recipes vanish on loading
The list of found recipes is kept only while the game runs. After a restart the player has to find everything again.
Fix: Tell your AI: save the list of found recipes with the game, and load it back before the first mix.
How to check it works
- You know no recipes yet. you mix water and herb: the tonic is found, and the game says so.
- Water and herb find the tonic. you mix herb first and water second, or the salve as herb, oil, herb: the same recipe is found, whatever the order.
- The tonic needs one herb and one water. you mix two herbs and one water: nothing is found and it counts as one wrong mix.
- You found the tonic and then made three wrong mixes. you mix the tonic again: the game says it is known and the count of wrong mixes stays at three.
- The hint comes after 5 wrong mixes in a row. you make 4 wrong mixes and then a fifth: there is no hint after the fourth, and after the fifth the game names one ingredient of the first missing recipe.
- A hint is showing after 5 wrong mixes. you find a recipe: the hint disappears, the count starts again at zero, and the next hint is about a recipe that is still missing.
- The table takes 4 ingredients and you have made 2 wrong mixes. you try to mix 5 ingredients: the mix is turned away and the count of wrong mixes stays at 2.
- The table is empty. you start a mix with nothing on it: the mix is turned away and nothing changes.
- The book has four recipes. you find all four: the book is complete, and further wrong mixes give no hint because nothing is missing.
Works well with
- Crafting System: Decide on purpose whether a wrong mix uses up ingredients. If it does, keep the cost small, or players stop experimenting. Discovery decides whether the player knows a recipe. Crafting then checks the materials and builds it.
- Inventory System: A turned-away mix must give every ingredient back. Take the ingredients from the inventory only when a mix is confirmed, and put them back if the player cancels.
Common questions
how do recipe discovery systems work in games
The player puts ingredients together and the game checks the pile against its recipes. A match unlocks the recipe for good. Most games add a hint after a run of failures so nobody stays stuck.
should crafting recipes be hidden or shown from the start
Hide them if experimenting is the fun of your game, and show them if players should plan ahead. A middle way is to show the recipe's name and result but hide the ingredients until it is found.
how many wrong tries before a hint
Start with 5 wrong mixes in a row. With few ingredients to choose from, 5 is a lot of guessing, and with many ingredients you can raise it to 10 or more.
what do i tell my ai to add recipe discovery
Paste this: Players find recipes by mixing ingredients on a table. The order does not matter but the amounts do. A found recipe is saved for good. After 5 wrong mixes in a row, show one ingredient of a recipe that is still missing.
Where it comes from
We could not find a reliable origin for this one yet.
What was checked
- 15 tests pass on the reference code.
- The state diagram was checked against the code, at the default values and at every listed low and high value.
Your AI gets the code
Tested example code comes through the Spielerando connection, so your AI can use it right away. How to connect it