Everything the man in the room does is decided by a stack of simple rules: what his body wants, how he feels, what just happened to him, and a little luck. This page explains each layer, with the real numbers the room is running on. The charts are drawn from the simulation's own data files, so they cannot drift from the code.
computer: arrow keys or WASD to walk, E or Enter to use what is near you, V to change the camera, M for music, Esc to close things. phone: drag the round stick at the bottom left to walk, tap the big pill at the bottom right to use what is near you, the camera icon at the top changes the view.
One pipeline, always in this order. Emotion is never an input to the first step: it is the result of what he did, and it only reaches back into his choices through mood and memory (so there are no instant feedback spirals).
Six slow, nearly fixed drives make up his personality. They push on faster-moving needs (motives). A drive's weight (0.5 to 1.5) multiplies how urgent its needs feel, so changing a weight changes his character without new code.
| drive | wants | feeds |
|---|---|---|
| vitality | body upkeep | energy, hunger, hygiene, bladder |
| stimulation | novelty, things to do | fun, curiosity, boredom |
| mastery | make and finish things | focus, pride |
| connection | company | social |
| security | a predictable safe place | comfort, stress |
| autonomy | roam and choose | restlessness, building |
Each need drains over time and is refilled by acts, with diminishing returns (the last 20% takes the longest):
drain m -= rate_m * (1 + a * stress) * dt refill m += reward * rate * (1 - m) * dt urgency u(m) = (1 - m)^2 * driveWeightUnder valence and arousal sit six slow variables, loosely inspired by neuromodulators. They are a game-grade abstraction, not real neuroscience: one molecule does not equal one emotion. Each one relaxes back to a baseline with its own time constant, and is pushed by events from the ledger.
dx/dt = (base - x) / tau + sum( event_i * weight_i )| variable | plays the role of | baseline | tau |
|---|
Four read-outs (valence, arousal, stress, dominance) are weighted sums of these variables. Blue pushes up, pink pulls down.
| read-out | bias | DA | HT | NE | CORT | OXY | SLP | mood |
|---|
| effect | DA | HT | NE | CORT | OXY | SLP |
|---|
Feelings are traces that fade. Each event adds a bump that decays exponentially, so a bad bump is felt for seconds, a bad stretch for minutes, a good day for the better part of an hour. Time keeps running while you are away, so a returning visitor finds him still carrying the day.
trace(t) = sum_i delta_i * exp( -(t - t_i) / tau )An emotion is a point in a five-number space (valence, arousal, stress, energy, dominance). The face you see is the nearest prototype, with hysteresis: he must cross a boundary by a margin before the face changes, so it never flickers. Dots below are the prototypes; colour is stress, size is how wide its territory is.
| emotion | valence | arousal | stress | energy | dominance |
|---|
Three variables (dopamine, serotonin, noradrenaline) each high or low give eight corners, a rough starting map from chemistry to feeling (after Lövheim 2012), blended with what just happened. It only counts when his chemistry is clearly away from its resting level.
| HT | DA | NE | Lövheim affect | leans toward |
|---|
Frustrated, the one people ask about, sits at high arousal and high stress (valence .28, arousal .75, stress .7). Wall bumps and interrupted acts feed it; it fades in about 25 to 45 seconds.
Every event writes one entry to the ledger: some points on needs and feelings, some chemistry, then it fades. The ledger is also the explanation: any mood can be traced back to the entries that caused it. Normal events are small and mostly pleasant. Erratic events (outside his pattern: hitting a wall, skipping a meal while starving, a 3 am shower) weigh about times more per point.
| event | kind | effect on feelings |
|---|
He has things he can do. Each one is tagged normal or erratic, trivial or not (a sigh versus cooking), and a category. Every act has its own formulas for whether he does it, how long it takes and how intense it is.
What he picks next is a weighted draw over every act's score. The score blends how much each act refills his most urgent needs, what he was just doing, how often he did it lately, and which acts naturally follow which (a table learned from public time-use diaries, so showers tend to follow sleep and meals tend to follow the fridge).
Chains are not a fixed list; they are planned. The room has a state (teeth clean or not, food cooked, dishes in the sink, caffeine in him, dressed or in pyjamas), and every act reads and changes it. What he wants most becomes a goal, and the planner puts in front of it whatever the world needs first: to eat he needs food, food needs cooking, cooking needs something from the fridge. Some steps are soft (brush before bed), kept more often when he is rested and calm. The order of steps that do not depend on each other is drawn from which acts tend to follow which and from his own habits, which strengthen each time he uses an order. So any permutation can happen, and each run of his life grows its own routine.
goal = draw(score) plan = fill(unmet preconditions of goal, recursively) order ~ affinity x (1 + habit)Interruptions and branches fall out of the same rule. A detour or a knock suspends the goal; he comes back with odds that fade with time away and with every restart, and replans from the state the room is in then, so steps already done stay done. A step that fails (food burnt) leaves a precondition unmet, and the replan is the branch (eat a snack instead). Over 200 simulated weeks he lives thousands of distinct sequences. The named chains below are just recognised motifs: finishing one pays a bonus into the ledger; breaking one costs, scaled by how many steps were left, and the next sequence is drawn from its branches (filtered by what broke it and how he feels).
| chain | kind | steps |
|---|
Not everything goes to plan. Seeded random events (so everyone watching sees the same one at the same moment) fire at a rate that rises with stress and fatigue:
rate(t) = h0 + kStress * stress + kFatigue * fatigue + trigger(t) events per second| event | base rate | stress adds | fatigue adds | trigger |
|---|
Even a normal act can go well or badly. Each act has a distribution over outcomes, nudged by fatigue, stress, skill and clutter:
No stage is a pure function of the one before it. Each carries noise, a slowly drifting gain that wanders and returns to centre, and some cross-talk into its neighbours (stress mistaken for hunger, loneliness for boredom). He also keeps a self-model of what he expects to happen; the gap between expectation and outcome feeds dopamine (good surprise) and cortisol (bad surprise). Four hidden regimes shift all the noise levels, and emotion labels describe the regime rather than choosing it.
| regime | noise x | typical stay (hours) |
|---|
Hand-set numbers made a believable person only by luck, so the numbers were searched. About 20 targets describe a believable, varied, stable life (sleep 6 to 9 hours, 2 to 4 meals, no single act hogging the day, never stuck asleep or starving). Each target has a band; being outside costs a penalty and "hard" targets must hold on every test run. A search over 50 factors (decay rates, pulls, penalties) minimised the total penalty, then the winner was re-checked on 480 simulated lives of 14 to 20 days using seeds it had never seen.
He is one person for everyone. His life is a pure function of a fixed seed and the real clock, with a saved checkpoint every four weeks, so any two visitors see the same man doing the same thing. What you do (bump him, startle him, knock at the door) is a small private layer on top that never changes his real life. While nobody is looking, time still passes and he lives it, up to two weeks act by act and in bulk beyond that.
Each of the piano and guitar pieces was analysed for how it feels (calm, tense, bright, nostalgic) and stored with the emotions it suits and how much it relieves stress. When he plays keys or guitar he picks the piece whose feeling is closest to his mood, and leans toward soothing pieces when stress is above .45. Pieces are public-domain or openly licensed scores; each is credited where it plays.
| layer | made with |
|---|---|
| the man | a 3D toon figure built in Blender, faces drawn per emotion, posture driven by the same numbers |
| the room | three.js, hand-built furniture, riso-print look |
| the sim | plain JavaScript modules that run in your browser and in node for testing; data lives in JSON files and a generator bakes them into the site |
| checks | 47 simulation tests (determinism, bounds, decay, hysteresis, catch-up), 200-life Monte Carlo runs, and a design test of the page itself |
| hosting | Cloudflare Pages, with a small database that keeps the shared state |