Tech Tree
A tech tree is a set of projects the player researches over time. Each has a price, an amount of work and other projects that must be finished first. One runs at a time while the rest wait in a queue. The price is paid at the start, and cancelling gives back only part of it.

Paste this to your AI
Copy it into Claude, Cursor or ChatGPT. It already has good values and the usual mistakes in it.
Add "Tech Tree" to my game.
What it should do: A tech tree gives the player a long goal to plan toward. Choosing what to research next, and waiting for it, makes each unlock feel earned and shapes how the player plays in between.
Build it exactly as this state machine. First check that it fits my game, then build it like this:
```mermaid
stateDiagram-v2
[*] --> idle
idle: Nothing queued
researching: Researching
stalled: Waiting for money
idle --> researching: queues, can pay
idle --> stalled: queues, cannot pay
stalled --> researching: income covers the price
stalled --> idle: queue cancelled
researching --> idle: last one ends or goes
researching --> stalled: ends, next unaffordable
```
Use these starting values:
- researchRate: 1 work/s
- cancelRefund: 0.5 x
- queueLimit: 4 projects
- startingBank: 25 money
Watch out for these common mistakes:
- Paying at the wrong moment: Tell your AI: take the price when the project starts, and let it wait without a price while it is in the queue.
- A cancelled project that others wait on: Tell your AI: when a project goes, take out every queued project that needs it, and every project that needs those.
- Time lost between two projects: Tell your AI: carry the rest of the time over to the next project in the same tick.
- Cancel and restart for money: Tell your AI: refund only a share of the price, less for work already done, and lose the work, so a restart always costs something.
- Waiting for money with nothing to say: Tell your AI: keep that state apart from idle, show that research is waiting for money, and start the project the moment income covers it.
- Tree with a loop or a missing project: Tell your AI: check the whole tree once, when the game loads, and list every loop and every missing project.
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 tech tree gives the player a long goal to plan toward. Choosing what to research next, and waiting for it, makes each unlock feel earned and shapes how the player plays in between.
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 queued → Researching: queues, can pay
- Nothing queued → Waiting for money: queues, cannot pay
- Waiting for money → Researching: income covers the price
- Waiting for money → Nothing queued: queue cancelled
- Researching → Nothing queued: last one ends or goes
- Researching → Waiting for money: ends, next unaffordable
Good starting values
| Value | Start with | What it changes |
|---|---|---|
| researchRate | 1 work/s | How much work gets done each second. It sets how long the projects take, and is never zero, or research would stand still for ever. |
| cancelRefund | 0.5 x | The share of the price handed back for the unfinished part of a cancelled project. The work already done is lost, so changing your mind always costs something. |
| queueLimit | 4 projects | How many projects may wait behind the running one. A short queue keeps the player choosing, a long one lets them plan an evening ahead. |
| startingBank | 25 money | What the player has when the game begins. Enough for the first project or two, so research can start at once. |
What usually goes wrong
Paying at the wrong moment
If the price is taken when a project is queued, a long queue locks up the player's money for ages, and cancelling it needs a refund. If it is never taken, the player queues things they cannot afford.
Fix: Tell your AI: take the price when the project starts, and let it wait without a price while it is in the queue.
A cancelled project that others wait on
If a project is taken out of the queue but those that need it stay, a project is left waiting for something that will never finish, and the queue is stuck for ever.
Fix: Tell your AI: when a project goes, take out every queued project that needs it, and every project that needs those.
Time lost between two projects
A long tick or a slow frame can run past the end of a project. If the rest of the time is dropped, many short projects take much longer than they should.
Fix: Tell your AI: carry the rest of the time over to the next project in the same tick.
Cancel and restart for money
If a cancel gives back the full price and keeps the work done, the player can cancel and restart for free, or refund and be paid for the pause.
Fix: Tell your AI: refund only a share of the price, less for work already done, and lose the work, so a restart always costs something.
Waiting for money with nothing to say
A queue whose first project cannot be paid just sits there, and the player does not know why nothing is happening.
Fix: Tell your AI: keep that state apart from idle, show that research is waiting for money, and start the project the moment income covers it.
Tree with a loop or a missing project
A project that needs itself, directly or through others, can never be started. One that needs something that does not exist is the same.
Fix: Tell your AI: check the whole tree once, when the game loads, and list every loop and every missing project.
How to check it works
- A new game with nothing researched. The player tries to queue irrigation, which needs pottery: It is refused and nothing changes.
- A new game with nothing researched. The player queues pottery, then irrigation, then trade, which also needs looms: Pottery runs, irrigation waits behind it, and trade is refused because looms is not there.
- 25 in the bank. The player queues pottery, a 10 project, and then weaving behind it: 15 is left once pottery starts and weaving, while it waits, has cost nothing.
- Pottery is running at one work per second. 2 seconds pass: Two of its five work are done.
- Pottery is running and needs 5 work. 5 seconds pass: Pottery is finished, nothing runs, and irrigation can now be queued.
- 100 in the bank and pottery queued with irrigation behind it. 7 seconds pass in one tick: Pottery finished at 5 seconds, irrigation has had 2 seconds of work, and 70 is left in the bank.
- 5 in the bank. The player queues pottery, a 10 project, and 100 seconds pass: Nothing has started, nothing was paid, and the research is waiting for money.
- Pottery is waiting with 5 in the bank. 5 more comes in: Pottery starts at once and the bank is 0.
- Pottery has had 2 of its 5 work done and 15 is in the bank. The player cancels it: 3 comes back, from 10 times half times three fifths, the bank is 18, and the work is lost.
- Pottery has had one second of work. The player cancels it and starts it again: The bank is lower than before and the work starts from zero.
- Pottery is running with irrigation, weaving and dyes behind it. The player cancels pottery: Irrigation and dyes are taken out, and weaving, which did not need it, starts.
- Pottery is finished. The player queues pottery again: It is refused and nothing changes.
- A queue limit of 1 and one project already waiting. The player queues a third: It is refused.
Works well with
- Currency Wallet: The bank in this mechanic can be the player's wallet, or a separate research budget. Take the price from the wallet when a project starts.
- Crafting System: A finished project can unlock recipes or buildings. Keep the unlock list on the project, so the tree stays the single place that says what a project gives.
- Skill Tree: A skill tree is bought at once with points and a tech tree takes time and money. A game can use both, one for the character and one for the world.
Variations: Skill Tree.
Common questions
what do i tell my ai to add a tech tree
Paste this: Add a tech tree: projects with a price, an amount of work and a list of projects that must be finished first. Run one at a time, queue the rest in order behind the ones they need, pay the price when a project starts, carry spare time over to the next project, and take out dependants when a project is cancelled.
what is the difference between a tech tree and a skill tree
A skill tree is spent at once with points and belongs to the character. A tech tree takes time and money, runs a project at a time, and usually belongs to a group, a town or the whole world.
should the player pay for research when it is queued or when it starts
When it starts. A queue then costs nothing until its turn, and cancelling a waiting project needs no refund. The price is the player's decision at that moment.
should a tech tree allow more than one project at once
It can. Give each running project its own place and share the research rate between them. One at a time is easier to read, and makes the order of choices matter more.
Where it comes from
We could not find a reliable origin for this one yet.
What was checked
- 20 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