NPC Daily Schedules
A daily schedule puts a character in a different place at different hours: at work in the morning, in the square at noon, at home at night. The character sets off early to arrive on time, stops walking while you talk, hurries if that made it late, and goes straight to the right place if the clock jumps.

Paste this to your AI
Copy it into Claude, Cursor or ChatGPT. It already has good values and the usual mistakes in it.
Add "NPC Daily Schedules" to my game.
What it should do: Characters with a routine make a world feel lived in, and they give the player a reason to plan: find the baker before noon, wait for the guard to leave, catch someone at the tavern.
Build it exactly as this state machine. First check that it fits my game, then build it like this:
```mermaid
stateDiagram-v2
[*] --> working
working: At a place
walking: Walking
hurrying: Hurrying
talking: Talking
working --> working: stays, or clock jumps
working --> walking: time to set off
working --> hurrying: already behind
working --> talking: player talks
walking --> walking: keeps walking
walking --> working: arrives or clock jumps
walking --> talking: player talks
hurrying --> hurrying: keeps hurrying
hurrying --> working: arrives or clock jumps
hurrying --> talking: player talks
talking --> talking: still talking
talking --> working: talk ends, stays
talking --> walking: talk ends, on time
talking --> hurrying: talk ends, behind
```
Use these starting values:
- travelHours: 0.25 h
- hurryFactor: 2
- skipHours: 2 h
Watch out for these common mistakes:
- Nobody before the first entry: Tell your AI: before the first entry of the day, the last entry of the day before still holds.
- Midnight breaks the clock: Tell your AI: work out the time that went by with the day wrapped round, so 23.9 to 0.1 is a fifth of an hour.
- The character walks through the whole night: Tell your AI: if the clock jumps by more than a set amount, in either direction, put the character at the place the timetable gives and skip the walking.
- The character pops in at the start time: Tell your AI: set off early by the walking time, so the character arrives when the entry starts.
- Stopped by a talk, then lost: Tell your AI: freeze the walk during the talk. Afterwards, if the character is behind the clock, let it walk faster until it arrives.
- Two entries closer than the walk: Tell your AI: let a started walk finish before the next one begins, and keep the entries in the timetable further apart than the walk.
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
Characters with a routine make a world feel lived in, and they give the player a reason to plan: find the baker before noon, wait for the guard to leave, catch someone at the tavern.
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
- At a place → At a place: stays, or clock jumps
- At a place → Walking: time to set off
- At a place → Hurrying: already behind
- At a place → Talking: player talks
- Walking → Walking: keeps walking
- Walking → At a place: arrives or clock jumps
- Walking → Talking: player talks
- Hurrying → Hurrying: keeps hurrying
- Hurrying → At a place: arrives or clock jumps
- Hurrying → Talking: player talks
- Talking → Talking: still talking
- Talking → At a place: talk ends, stays
- Talking → Walking: talk ends, on time
- Talking → Hurrying: talk ends, behind
Good starting values
| Value | Start with | What it changes |
|---|---|---|
| travelHours | 0.25 h | How many game hours a walk between two places takes. The character sets off this long before an entry starts, to arrive when it starts. Zero makes the character appear at once. Keep entries further apart than this. |
| hurryFactor | 2 | How many times faster a late character walks. Two catches up with a short delay and is still easy to read as hurrying. |
| skipHours | 2 h | A jump of the clock bigger than this counts as sleeping or skipping time, and the character goes straight to where the timetable says. Set it above the biggest step of your normal clock. |
What usually goes wrong
Nobody before the first entry
The first entry starts at six. At three in the morning no entry has started yet, so the code finds nothing and the character vanishes or stands in the wall.
Fix: Tell your AI: before the first entry of the day, the last entry of the day before still holds.
Midnight breaks the clock
The clock goes from 23.9 to 0.1. Subtracting gives a jump of minus 23.8 hours, and the code either skips a whole day or walks the character backward.
Fix: Tell your AI: work out the time that went by with the day wrapped round, so 23.9 to 0.1 is a fifth of an hour.
The character walks through the whole night
The player sleeps until morning and the clock jumps eight hours. The character walks from stop to stop in one blink, or is seen halfway between places.
Fix: Tell your AI: if the clock jumps by more than a set amount, in either direction, put the character at the place the timetable gives and skip the walking.
The character pops in at the start time
The entry says the character is at the square at noon. At noon it appears there, with no walk, and the player who watches it sees it flicker into place.
Fix: Tell your AI: set off early by the walking time, so the character arrives when the entry starts.
Stopped by a talk, then lost
The player talks to a character on the way to work. Afterwards the character either keeps walking as if no time passed and arrives an hour late, or jumps to the place.
Fix: Tell your AI: freeze the walk during the talk. Afterwards, if the character is behind the clock, let it walk faster until it arrives.
Two entries closer than the walk
The entries are ten minutes apart but the walk takes fifteen. The character is told to be in two places, and turns around halfway or never arrives anywhere.
Fix: Tell your AI: let a started walk finish before the next one begins, and keep the entries in the timetable further apart than the walk.
How to check it works
- A timetable with the bakery at six, the square at twelve and the tavern at nineteen. the clock runs from seven through the day: the character is at the bakery at seven, at the square after twelve and at the tavern after nineteen.
- A timetable whose first entry is at six and whose last entry, home, starts at twenty-three. the clock shows three in the morning: the character is at home.
- A character at the bakery and a walk of a quarter of an hour to the square, which starts at twelve. the clock runs from eleven to a little after twelve: the character stays at the bakery until a quarter to twelve, is walking just before twelve and is at the square by twelve.
- A character at home at night. the clock goes from 23.98 to 0.02 and on to the morning: the character stays at home through midnight, with no skip and no walk, and goes to the bakery in the morning.
- A character on its way to the square. the player talks to it for a while: the character stays exactly where it is on the way until the talk is over.
- A character at the bakery who should set off at a quarter to twelve. the player talks to it until after twelve: it stays, and sets off hurrying the moment the talk ends.
- A character that a talk made late. the talk ends: it walks at twice the normal speed and arrives at the square within a short time.
- A character on its way, still within a few minutes of the schedule. the player talks to it for a minute only: it keeps walking at the normal speed, not hurrying.
- A character at the bakery at seven, and one in the middle of a walk. the clock jumps to twenty, and for the second one to fifteen: the first is at the tavern at once, and the second is at the bakery, neither one walking.
- A character at the bakery at fifteen. the clock moves back, even by a very small amount: the character is at the place the timetable gives for that hour, not walking.
- A walking time of zero. an entry starts: the character is at its place in that same step.
Works well with
- Day-Night Cycle: If the schedule keeps its own clock, the two drift apart and characters go home in broad daylight. Let the day and night cycle own the clock, and pass its hour to the schedule at every step.
- Dialogue System: A character that keeps walking during a talk drags the speech bubble across the street. Tell the schedule that a talk has started before the first line is shown, and that it ended after the last one.
- World State Flags: After a load the character stands where the timetable puts it at that hour, so nothing about the walk has to be saved. Save the clock and the character's place, and rebuild the walk from them on load.
- Enemy Patrol and Chase: A chase that never hands control back leaves the guard stuck at the place where it gave up. Let a guard follow its timetable until something alerts it, and return to the timetable when it calms down.
Common questions
how do npc daily schedules work in games
Each character has a list of hours and places. The character is at the place of the last hour that has started, and walks to the next place just before its hour, so it arrives on time.
what happens to a schedule when the player sleeps or skips time
Do not walk the character through the missed hours. If the clock jumps by more than about two hours, put the character at the place the timetable gives for the new hour.
what should a character do when the player talks to it
Stop walking for the whole talk. When it ends, if the character is behind, let it walk about twice as fast until it arrives, so the day catches up without a jump.
what do i tell my ai to add character routines
Paste this: Give each character a timetable of hours and places. Before the first entry of the day, the last one from the night before holds. Characters set off a quarter hour early to arrive on time, stop while the player talks, hurry twice as fast if late, and if the clock jumps by more than two hours they go straight to the right place.
Where it comes from
We could not find a reliable origin for this one yet.
What was checked
- 16 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