Episode 2 found a way to model the operations of a restaurant, but only on the fifth try. This episode goes back to that struggle, and finishes with a high-quality, reusable, professional-grade DES implementation, at the cost of ~500 million tokens burned. Built by Pasha and Claude, 100% by voice: no code or commands entered by keyboard.
The finished product runs live on the next slide, inside this presentation. Nothing to install, nothing to configure.
Play with it live View the source code on GitHub
You can also see the source code of everything presented here, and how the application runs.
Press ▶ below to play with it. After that, ▶ continues with the story.
The restaurant simulator is running right now. Close this window, then interact with it:
When you are done, press ▶ below to continue.
CloseEpisode 1 left a restaurant drawn as a room: tables, waiters, cooks, a kitchen. Episode 2 set out to draw the same restaurant as a process: the work itself, so that it could be measured and improved. Getting from the floor view to a model of the process was the hard part, and Pasha said so at the start.
… add another view: a graph of the flow of work. I need your help, because I don't know exactly how to model it. Some things are stationary, like tables and stoves, and some move, like guests, waiters and food. How should I model this as a flow of work so that I can optimize the flow later?Pasha, in Episode 2, lightly trimmed
What followed took about half an hour. We built five versions of that view. Pasha threw four of them away and accepted the fifth.
| Version | What it was | What became of it |
|---|---|---|
| 1 | A flow graph: steps in a loop around the resources | Thrown away |
| 2 | A status board: tables, kitchen, people and equipment | Thrown away |
| 3 | The status board with arrows and motion | Thrown away |
| 4 | A workflow from left to right, with lanes | Thrown away |
| 5 | The same workflow, with queues drawn as columns | Thrown away |
| 6 | The service view: a party's states, two queues, the kitchen | Kept |
The first answer to Pasha's request for "a graph of the flow of work".
Thrown away.
Pasha described three sections, and we built them as a board of cards.
Thrown away: basically unusable.
Things start on the left and complete on the right, with nothing tied to the room. Much better than before: it shows clearly which actor is on which task.
Thrown away: nice, but very limited in what it could show.
Pasha pushed the workflow further, to see whether it could bring the resources in as well, with the things that wait drawn differently from the things that happen.
Thrown away.
The party's states as the foundation, with the two key queues, the order rail and the pass, as things of their own. This was what Pasha was looking for.
Kept: something that could be improved step by step, and good enough to take forward.
The four other views were deleted, and the rest of Episode 2 went into the one that was kept.
We decided to keep working with it. It worked, and it was accepted. It was also still a picture of this one restaurant: its boxes, its two queues, its kitchen.
It worked, but it did not feel like a solid design. After sleeping on it, Pasha decided to do another pass.
The service view worked, but it was a picture made up for this one restaurant. The problem itself is an old one with standard answers, so Pasha took it to another model to see how it would explain them.
I want to be able to model this as a formal process because in order to cook, a cook has to work on a stove, so while he's working, the other cook cannot use the same stove. We have to wait for people to read the menus before they can order, and then in order to order, a waiter has to be available, but if he's busy, he's not available. It sounds like there's a bunch of queuing, coordination, resource acquisition locking. There has to be a standard mechanism for doing all of that.Pasha, to Gemini, lightly trimmed
Gemini answered with three established formalisms:
| Formalism | Best for | What it gives you |
|---|---|---|
| Petri nets | Proving that the process is correct | Proofs that it cannot deadlock and that queues stay bounded |
| Discrete event simulation | Sizing and finding bottlenecks | How busy each thing is, how long the waits are, where work piles up |
| Process calculi and actors | Designing software that runs in parallel | Safe message passing between independent parts |
Okay, so tell me in this three ways methods you proposed, what is the visitor, what is a stove, is a standard notation in terms of terminology that should be used in modeling across these three things and methodologies.Pasha, to Gemini
| In the restaurant | Petri nets | Discrete event simulation | Process calculi |
|---|---|---|---|
| A party | Token | Entity | Process, or message |
| A stove | Token in a resource place | Resource | Shared channel |
| A waiter or cook | Token in a resource place | Resource, seized and released | Worker process |
| Waiting | Place | Delay, or queue | Blocked state |
A fair answer to the question, and still in the formalisms' own words: tokens, places, entities, channels.
Every word of the answer was right, and Pasha knew it: the mathematics of all three methods was familiar to him. That was not the difficulty.
The difficulty was who the video is for. Cyber Kitchen is meant to introduce the running of a restaurant to a business major, and someone with a bachelor's degree in business does not know these methods.
Mathematically correct advice, and not applicable to the people it had to reach.
To be widely used, it needed to be a much simpler model.
A transition Begin Cooking requires one token from Order Placed, one token from Cook Available, and one token from Stove Available. It fires atomically and consumes all three.
Stochastic Petri Nets (GSPN): Durations follow probability distributions, allowing Markov chain analysis for throughput and bottleneck discovery.
… the place P_available_stoves is initialized with a marking of M₀(P_available_stoves) = 4.
Petri Nets let you prove structural properties mathematically: Deadlock-freedom … Liveness, and Boundedness.
with stove.request() as req: yield req
Formulates resources as semaphores or mutexes. Useful for proving absence of classic concurrency bugs (e.g., the Dining Philosophers problem …).
Pieces of Gemini's first answers, as written. The highlights are ours: each is a term a business major would have to be taught first.
So Pasha put the question again, this time as his audience would ask it. Anyone in business can do the same with an AI tool: say who you are, and ask which option would be easiest for you.
I don't want to learn about those methods. I want to know how to model the restaurant.Pasha, to Gemini
Okay, so I'm a non-software engineer. I have a business degree. What method is most appropriate for a medium-sized restaurant, not a chain, one restaurant, that would be easy for me to understand, implement, and manage forward?Pasha, to Gemini
Gemini's answer was discrete event simulation (DES), and Pasha agreed: it is the easiest of the three. The other two are for proofs and for software, while this one "speaks the language of business metrics" and is taught in operations courses. It needs only three kinds of thing.
| Building block | What it is | In the restaurant |
|---|---|---|
| Entity | What flows through and gets finished | A party, and its order |
| Resource | Limited capacity that is seized and released | Tables, waiters, stoves |
| Delay or queue | Time that passes: the guests' own time, or waiting for a resource | Reading the menu is a delay; a ticket waiting for a free stove is a queue |
These are the words the Process Map of Episode X ended up using: parties, resources, and a waiting area in front of every task.
We had settled on DES, but DES is an approach, not a plan. How would it be built into the restaurant app we already had? Pasha first asked in general.
I would like to move away from the physical location of the restaurant to formal formalism like DES. So how to make that transition?Pasha, to Gemini
Gemini's answer was correct and very abstract: one engine as the only source of truth, every physical thing renamed as a resource, an entity, a delay or a queue. The better way to ask was to look at specific projects, see how each one does it, and borrow from there.
Find few articles that describe use of DES for modeling restaurant operations. [...] Figure out how modeling is done specifically. What are the entities, how they modeled, so it's not theoretical how you inferred it, but based on articles how people actually do it.Pasha, to Gemini, in two messages
| Source, as Gemini gave it (we have not read the papers ourselves) | What it models, in Gemini's summary |
|---|---|
| A Simulation Model for Managing Customer Waiting Time in Restaurants: Scenarios and Beyond (British Food Journal, 2020) | An upscale restaurant: servers, chefs and tables against customers who grow anxious when they wait too long, and the customers who are lost |
| Simulation Helps Local Restaurant Reconfigure Operations (European Conference on Modelling and Simulation, 2025) | One independent restaurant: whether tables or servers are the bottleneck at lunch and at dinner |
| Discrete Event Simulation Using Python SimPy (a two-part article on Medium) | Tables and staff as resources; the life of a party from arriving to leaving; queues building up |
| Enhancing the Overall Customer Experience Through Simulation of Hybrid Ordering System in Fast-Food Restaurants (Taylor & Francis) | Layouts and who does what: how the kitchen's capacity limits everything else |
This was the answer that could be used. It is not a method to learn but a handful of decisions that practitioners have already made, each of which can be said in plain words.
| What the studies do | In plain words |
|---|---|
| The entity is the party | Follow the group at the table, not each guest |
| The order is a second entity | The party stays at its table; the order travels through the kitchen; the two meet again when the food arrives |
| Tables, waiters and stoves are pools | A table is held for the whole visit; a waiter is taken for a moment and given back, never held while guests read or eat |
| A dish needs two things at once | A cook and a stove, at the same moment; a free cook cannot start without a free stove |
| Waiting is kept apart from doing | Time spent waiting for someone or something is counted separately from the time the work takes |
| Nothing depends on where things are drawn | No walking paths or positions in the logic: only who holds what, and who is waiting |
With the method chosen and the modelling decisions borrowed, Pasha started the build with Claude. It went back and forth many times, but looking back it had five phases.
We knew the method and the terminology by now. It still took three iterations to get it right.
What is wrong with it:
The second was built from scratch from the decisions borrowed from the studies. It came out as a flowchart.
The third was a whole new view, built on a real event engine, with the guests as actors.
After three that were not kept, this is the basic DES model that was. It had very good, solid foundations:
But it had a few weaknesses:
The metrics do not belong in a process flow. The next iteration moved them elsewhere and decluttered.
The first view was functionally correct but not yet usable. Phase 2 made it a clean interface in three moves, each borrowing a concept from a rejected attempt.
The process map itself stayed clean from the first step. What this phase added was a natural way to explore it, with a lot of nuance behind it.
The other polish: instead of looking at the whole thing, you can focus on any one element of the model.
The side panel's Metrics tab is where each object is measured against what it is for.
Each object also carries the actions that make sense for it. This is very powerful: it lets you control scenarios dynamically, while the restaurant runs.
The purpose of the Scorecard is to level up: from the metrics of each component of the process map to the actual business metrics, the ones that cut across all of them.
This is just the beginning of the high-level business metrics. Episode 3 will build them out toward the owner's actual objectives.
I think we are functionally complete. Now write the full test suite and capture screenshots. … I want very high test coverage.Pasha, to Claude
test_the_right_click_menu_is_only_about_this_object.Estimated from the session's log: 113 requests from the ask for tests to the start of this journey. A few small features are in that stretch too, so the tests alone cost somewhat less.
Deployed as a single HTML page with everything bundled in. No third-party libraries: everything was built and tested from scratch. Built by Pasha by voice: the keyboard was not touched through any of it.
This is probably not something a business major could do, even with the same AI tools. Better left for a professional software engineer.
Counted from the session's own log: 431.0 million tokens across 918 requests to the model, all Claude Opus 5.5. This covers the build and the writing of this journey, up to this slide.
| Kind | Tokens | What it is |
|---|---|---|
| Re-read from cache | 425,126,783 | The conversation so far, read again on every request. This is 98.6% of the total and is billed at a small fraction of the normal rate. |
| New input | 4,562,535 | Text entering the conversation for the first time: Pasha's messages, tool results, files and screenshots. |
| Output | 1,317,248 | Everything Claude wrote: answers, code, commands and its working notes. |
| Total | 431,006,566 |
The total is large because of how a long conversation works, not because much was written. Each of the 918 requests re-reads everything before it, so the same text is counted again and again: on average about 463,000 tokens of history per request. Episode 2 took 49.4 million tokens; this one took about 9 times as much.
Other statistics
We burned about $148 in tokens to get this done, at the prices of Claude Opus 5.5, the model that ran the session.
| Model | Rough cost | Notes |
|---|---|---|
| Claude Opus 5.5 | about $148 | What we used: $85.03 for cache re-reads, $36.49 for new input, $26.34 for output. |
| Claude Sonnet 5.5 | about $116 | The same token counts at Sonnet's prices. Its cache-read price is the same as Opus. |
Caching is what keeps this small. With no caching, every re-read would be billed as fresh input: about $1,750 on Opus 5.5.
The conversation that built the page, with Pasha's words as spoken, is in TRANSCRIPT.md.
You are here.
Next, Episode 3: building the business metrics out toward the owner's actual objectives.
There is more from Semantic Works to explore.
Happy vibe coding with LLM AI!
Click the picture for twice the size · move the mouse to look around · Escape to close