Crop Farming
Crop farming lets the player plant a seed, water it and harvest it later. The crop grows only while the soil is wet, ripens after a set time, rots if left too long, and wilts if it stays dry. Time away is worked out fairly, so a long break gives the same result as playing through 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 "Crop Farming" to my game.
What it should do: Farming gives the player a slow, caring loop with a reward at the end. Planting is a small bet on the future, watering is the attention it asks for, and harvest day is the payoff that brings the player back.
Build it exactly as this state machine. First check that it fits my game, then build it like this:
```mermaid
stateDiagram-v2
[*] --> empty
empty: Bare soil
growing: Growing
ripe: Ready to pick
wilted: Wilted
empty --> growing: plants a seed
growing --> ripe: grown enough
growing --> wilted: dry for too long
ripe --> empty: harvested
ripe --> wilted: left for too long
wilted --> empty: cleared away
```
Use these starting values:
- growTime: 120 s
- wetTime: 90 s
- witherAfter: 60 s
- rotAfter: 180 s
- harvestAmount: 3 items
Watch out for these common mistakes:
- The player was away for hours: Tell your AI: when time has passed, split it. The first part is wet time, as long as the soil stayed wet, and the rest is dry time. Only the wet part grows the crop.
- The crop ripens and rots in one long step: Tell your AI: when the crop ripens inside a step, count the rest of the step as ripe time, and check for rot right away.
- Watering before planting is wasted: Tell your AI: the wetness belongs to the soil, not to the crop. Let it run down on an empty plot, and keep it when a seed goes in or a crop is picked.
- Planting on a busy plot eats the seed: Tell your AI: only plant in an empty plot, and only take the seed when the game reports that something was planted.
- Picking too early destroys the crop: Tell your AI: harvest does nothing unless the crop is ripe. Show the player that the crop is not ready yet.
- One late watering is not forgiven: Tell your AI: any wet time starts the dry count over from zero.
- A seed that is planted in a long step ripens at once: Tell your AI: time that passes during the planting step does not count. The crop starts to grow on the next step.
- Growth keeps running on dry soil: Tell your AI: add to the growth only the wet part of each step.
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
Farming gives the player a slow, caring loop with a reward at the end. Planting is a small bet on the future, watering is the attention it asks for, and harvest day is the payoff that brings the player back.
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
- Bare soil → Growing: plants a seed
- Growing → Ready to pick: grown enough
- Growing → Wilted: dry for too long
- Ready to pick → Bare soil: harvested
- Ready to pick → Wilted: left for too long
- Wilted → Bare soil: cleared away
Good starting values
| Value | Start with | What it changes |
|---|---|---|
| growTime | 120 s | How many seconds of wet soil a crop needs to ripen. Two minutes suits a quick first crop; longer crops should pay more. |
| wetTime | 90 s | How long one watering keeps the soil wet. Shorter than the grow time, so the player has to come back and water more than once. |
| witherAfter | 60 s | How long a growing crop may stay dry before it wilts. A forgiving window, so one missed watering is not the end. One watering starts the count over. |
| rotAfter | 180 s | How long a ripe crop may wait before it rots. Long enough that the player is not punished for a short break, short enough that the harvest matters. |
| harvestAmount | 3 items | What one harvest gives. More than one, so that planting pays back more than the seed that went into it. |
What usually goes wrong
The player was away for hours
The game was closed, and on return it gives the crop no growth at all, or the whole time as growth although the soil dried out after a minute.
Fix: Tell your AI: when time has passed, split it. The first part is wet time, as long as the soil stayed wet, and the rest is dry time. Only the wet part grows the crop.
The crop ripens and rots in one long step
A long step covers both the end of growing and a long wait afterwards. If the game only checks 'is it ripe now', a crop that rotted long ago is shown as fresh.
Fix: Tell your AI: when the crop ripens inside a step, count the rest of the step as ripe time, and check for rot right away.
Watering before planting is wasted
The player waters bare soil and then plants. If the game forgets the wet soil, the player has to water a second time, and it feels like a bug.
Fix: Tell your AI: the wetness belongs to the soil, not to the crop. Let it run down on an empty plot, and keep it when a seed goes in or a crop is picked.
Planting on a busy plot eats the seed
The player presses plant on a plot that already has a crop. The game takes a seed out of the bag but plants nothing, or it replaces the crop that was growing.
Fix: Tell your AI: only plant in an empty plot, and only take the seed when the game reports that something was planted.
Picking too early destroys the crop
The harvest button works on any crop. A player who presses it on an unripe plant loses the plant and gets nothing.
Fix: Tell your AI: harvest does nothing unless the crop is ripe. Show the player that the crop is not ready yet.
One late watering is not forgiven
The dry time keeps counting up even after the player waters, so a crop that was dry for 50 seconds, then watered, wilts 10 seconds into its next dry spell.
Fix: Tell your AI: any wet time starts the dry count over from zero.
A seed that is planted in a long step ripens at once
The player plants as the game catches up on a long stretch of time. If that time counts for the new seed, it is ripe in the same moment it was planted.
Fix: Tell your AI: time that passes during the planting step does not count. The crop starts to grow on the next step.
Growth keeps running on dry soil
The game adds time to the growth every tick, wet or not. Watering then does nothing, and the crop ripens even when it is ignored.
Fix: Tell your AI: add to the growth only the wet part of each step.
How to check it works
- An empty plot. the player plants a seed: a crop is growing, and the game says a seed was used on that tick only.
- A crop that needs 10 wet seconds, and a seed planted during a step of 500 seconds. the step ends: the crop is growing with 0 growth, not already ripe.
- A crop that has grown for 50 seconds, and a wilted one. the player tries to plant on each: no seed is used and the 50-second crop keeps growing.
- A crop in soil watered once. 90 seconds pass, then 30 seconds more: it has grown 90 seconds and the 30 dry ones added nothing.
- Bare soil that is watered. 10 seconds later a seed goes in, and then 10 more seconds pass: the crop has already grown 10 seconds, since the planting tick itself gave it no time.
- A crop in soil that stays wet. it has had 120 seconds of wet soil: it is ripe on the second that completes it, and not at 119.
- A crop whose soil has just dried. it stays dry for 59 seconds and then one more: it is still growing at 59 and wilted at 60.
- A crop that has been dry for 59 seconds. the player waters it, and the soil dries again later: the dry count starts again at 0, so it survives another 59 dry seconds.
- A ripe crop. the player harvests: 3 items come out once and the plot is empty.
- A crop that is not ripe, or a wilted one. the player tries to harvest: nothing is given and the crop is untouched.
- A ripe crop that is not picked. 180 seconds pass: it is fine at 179 and rotten at 180, and can no longer be harvested.
- A wilted crop. the player clears the plot: the plot is empty and its growth is 0.
- A growing crop and a ripe one. the player tries to clear each: both stay as they are.
- A freshly planted crop. it rains for 120 seconds: it is ripe without any watering by the player.
- A crop in soil watered once, and the player away for 100 seconds. the 100 seconds are worked out as one step or as 100 steps: both give 90 seconds of growth and 10 seconds dry.
- A crop that needs 30 wet seconds, in soil watered once. 100 seconds pass in one step, and in another case 250: after 100 it has been ripe for 70 seconds, and after 250 it has rotted.
Works well with
- Day-Night Cycle: Growth can follow game days, or sleep can skip ahead. Pass the skipped time to the plot as one long step. Use the game clock for the time that passes, not the real clock.
- Season Track: Change the values when a season starts, never in the middle of a growing crop, so the crop does not jump. Let the season change the grow time or decide which crops may be planted.
- Inventory System: Check for room in the bag before harvesting, or the crop is lost with nowhere to go. Take the seed only when the plot says something was planted, and add the harvest after the plot says so.
- Idle Income: Both need fair offline time. Share the way you count time away so they cannot disagree. Work out time away with the same long step as the farm.
- Hunger and Thirst: Farming then answers hunger. Check that a patch of crops can feed the character before the bar runs out. Let harvested food feed the character.
Common questions
how do i add farming to my game
Paste this: Add farming. A plot can be empty, growing, ripe or wilted. A seed goes only into an empty plot. A crop grows only while the soil is wet, and watering keeps it wet for 90 seconds. After 120 seconds of growth it is ripe, and picking it gives 3 items. Dry for 60 seconds wilts it, and waiting 180 seconds when ripe rots it.
how do i grow crops while the player is away
Save the time when the player leaves. On return, take the time that has passed and give it to the plot as one long step. The plot works out how much of it was wet and how much was dry, so you never need to run every second.
should crops die if you forget them
A gentle version works best: a crop that stays dry for a minute wilts, but one that waits ripe for a few minutes only rots. A hard penalty on a short break makes a calm game feel stressful.
why does my crop ripen even when i never water it
The growth is added every tick, wet or not. Add only the part of each step in which the soil is wet.
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