Experimental · timings and targets in the simulation are invented
Semantic Works: Cyber Kitchen: Episode X: 500 Million Tokens to Cook One Process Map
October 2026

Cyber Kitchen:
Episode X: 500 Million Tokens to Cook One Process Map

A hundred-dollar bill on fire

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.

Dr. Pavel (Pasha) Simakov
About the author
Dr. Pavel (Pasha) Simakov Managing Partner, Semantic Works LLC linkedin.com/in/pavelsimakov
Before the story

Play with it right away

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.

What you are about to experience is live.

The restaurant simulator is running right now. Close this window, then interact with it:

  • Click a task, a resource, an outcome or one square to see what it is and how it is doing against its target.
  • Switch views with the blue button at the top: Floor Plan, Process Map, Scorecard.
  • Right-click anything to pin it, call a cook in sick or break an oven. Change the staff with the minus and plus buttons.

When you are done, press ▶ below to continue.

Close
Looking back at Episode 2

In Episode 2 there was a moment when Pasha struggled

Episode 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.

VersionWhat it wasWhat became of it
1A flow graph: steps in a loop around the resourcesThrown away
2A status board: tables, kitchen, people and equipmentThrown away
3The status board with arrows and motionThrown away
4A workflow from left to right, with lanesThrown away
5The same workflow, with queues drawn as columnsThrown away
6The service view: a party's states, two queues, the kitchenKept
Version 1 of 5 · 0:07 – 0:14 into Episode 2thrown away

Version 1: a flow graph

The first answer to Pasha's request for "a graph of the flow of work".

Thrown away.

A loop of twelve step boxes with a resources panel in the middle
Version 1: the flow graph.
Version 2 of 5 · 0:16 – 0:20 into Episode 2thrown away

Version 2: a status board

Pasha described three sections, and we built them as a board of cards.

Thrown away: basically unusable.

A board with three sections of cards: tables, kitchen, and people and equipment
Version 2: the status board.
Version 3 of 5 · 0:27 – 0:31 into Episode 2thrown away

Version 3: a workflow, from left to right

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.

A row of twelve step boxes with four lanes below and a few markers in them
Version 3: the workflow, left to right.
Version 4 of 5 · 0:31 – 0:34 into Episode 2thrown away

Version 4: the workflow, with queues as columns

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 workflow with dashed orange queue columns and a wide dashed area for guests waiting for food
Version 4: the workflow, with queues as columns.
Version 5 of 5 · 0:36 – 0:38 into Episode 2kept

Version 5: the one Pasha accepted

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.

Party state boxes along the top, two dashed queues below, and a Cook box with four slots
Version 5: the service view, in its first form.
The end of Episode 2

Finally, this is what we finished

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.

The finished service view 2:30 into service
The service view as Episode 2 left it.
After Episode 2

Good enough, but not a solid design

It worked, but it did not feel like a solid design. After sleeping on it, Pasha decided to do another pass.

Between Episode 2 and Episode X · a conversation with Gemini

Pasha asked whether there was a standard way to do this

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:

FormalismBest forWhat it gives you
Petri netsProving that the process is correctProofs that it cannot deadlock and that queues stay bounded
Discrete event simulationSizing and finding bottlenecksHow busy each thing is, how long the waits are, where work piles up
Process calculi and actorsDesigning software that runs in parallelSafe message passing between independent parts
The same conversation

Asking for plain names got three more vocabularies

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 restaurantPetri netsDiscrete event simulationProcess calculi
A partyTokenEntityProcess, or message
A stoveToken in a resource placeResourceShared channel
A waiter or cookToken in a resource placeResource, seized and releasedWorker process
WaitingPlaceDelay, or queueBlocked state

A fair answer to the question, and still in the formalisms' own words: tokens, places, entities, channels.

A table from Gemini titled Comparative Terminology Map: for Petri nets, discrete event simulation and process calculi, what each calls the visitor, the stove, the waiter or cook, and the state of waiting
Gemini's answer: three formalisms compared. Click to enlarge.
The same conversation

The advice was correct, and it was for a different audience

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.

The same conversation

Choosing DES

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 blockWhat it isIn the restaurant
EntityWhat flows through and gets finishedA party, and its order
ResourceLimited capacity that is seized and releasedTables, waiters, stoves
Delay or queueTime that passes: the guests' own time, or waiting for a resourceReading 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.

The same conversation · the objective

How would DES be built into our app? Ask how specific projects did it

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
The key learning

What we learned from other projects

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 doIn plain words
The entity is the partyFollow the group at the table, not each guest
The order is a second entityThe party stays at its table; the order travels through the kitchen; the two meet again when the food arrives
Tables, waiters and stoves are poolsA 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 onceA cook and a stove, at the same moment; a free cook cannot start without a free stove
Waiting is kept apart from doingTime spent waiting for someone or something is counted separately from the time the work takes
Nothing depends on where things are drawnNo walking paths or positions in the logic: only who holds what, and who is waiting
Episode X · the build

Then came the build: 127 turns with Claude, in five phases

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.

  1. Get the DES model to work. One engine, the basics of parties, tasks, resources and queues. Even knowing the method and the terminology, it took three iterations before one looked good.
  2. Polish the starting DES into a clean interface. Actors and outcomes introduced, and queues folded into the tasks.
  3. Make it intuitive to explore. Select and inspect any element, zoom in and out, focus on one part of the process; a side panel explains each element, with its objectives and metrics.
  4. Separate two kinds of metrics. Observability of each task and resource, such as the oven or the planning of a ticket, stays next to the object it measures. The business metrics that cut across them, derived from those, are pulled out into their own view: the Scorecard.
  5. Build the full test suite. Close to 500 test cases, including UI validation in Chromium against reference screenshots.
The build · phase 1 of 5 · attempt 1 of 4thrown away

Attempt 1, wrong: tasks in lanes

We knew the method and the terminology by now. It still took three iterations to get it right.

What is wrong with it:

Tasks arranged in three lanes for visitors, waiters and cooks, with tables and equipment below
Tasks in lanes, with the resources underneath.
The build · phase 1 of 5 · attempt 2 of 4thrown away

Attempt 2, rejected right away: a flowchart, not DES

The second was built from scratch from the decisions borrowed from the studies. It came out as a flowchart.

A flowchart of the study model: party flow on top, ticket flow below, pools as boxes joined by dashed lines
The study model drawn as a flowchart.
The build · phase 1 of 5 · attempt 3 of 4not kept

Attempt 3, all good, but hard to follow and too busy

The third was a whole new view, built on a real event engine, with the guests as actors.

Stations in two rows with queue and work areas, tables and equipment below, and objectives for a visit
Stations, actors and resources. The picture shows it after the kitchen was made parallel.
The build · phase 1 of 5 · attempt 4 of 4 · turns 1 to 49kept

Phase 1: finally, the one that looked good as DES

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 Process Map: a chain of queue and task boxes from Arrivals to Dining, the kitchen forking into three parts, and pools of tables, waiters and cooks
The Process Map in its first form, 1 hour 7 minutes in, then called "view 6: Pipeline". Queues are still boxes of their own, and there are no outcomes yet. Rebuilt from the session's record.
The build · phase 2 of 5 · from a starting DES to a polished DES

Phase 2: polish the first view toward usability

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 pipeline with each queue folded into its task as a dashed waiting area on the left, and only two ways out, turned away and departed
The Process Map early in phase 2, with the queues folded into the tasks.
The build · phase 3 of 5 · turns 9 and 52 to 67

Phase 3: intuitive to explore, inspect and focus

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 side panel on one selected party, its About tab
The side panel on one selected party.
The build · phase 3 of 5

Phase 3, continued: focus on any one element

The other polish: instead of looking at the whole thing, you can focus on any one element of the model.

The Process Map with the Bake pizza task pinned in the middle
Zoomed in: "Bake pizza" pinned, with what feeds it, what follows, and what it needs.
The build · phase 3 of 5 · turns 61 to 67

Phase 3, continued: every object has its own objective and metrics

The side panel's Metrics tab is where each object is measured against what it is for.

The Metrics tab for the pizza oven: how it is measured, use every 15 seconds against an 80% line, use on the clock, the target, and 48% within the limit
The pizza oven's metrics: how it is measured, two charts, its target and a verdict.
The build · phase 3 of 5 · turns 57 and 119 to 121

Phase 3, continued: control actions, attached to specific elements

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 Actions tab for Cook 1: pin, and call in sickThe Floor Plan with Table 5 selected: its Actions tab offers Close table, while tables 6 and 7 and the pizza oven are already out of service
Cook 1 can be pinned or called in sick. Table 5 can be closed, beside tables 6 and 7, which already are.
The build · phase 4 of 5 · turns 68 to 79

Phase 4: the owner's numbers get their own view

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.

The Scorecard: nine tiles with Little's Law footnote, and the side panel showing the metrics of Average wait for food against a target of at most 1:00
The Scorecard, with the metrics of one tile, the average wait for food, open beside it.
The build · phase 5 of 5 · turns 123 to 126

Phase 5: the full test suite, with screenshots

I think we are functionally complete. Now write the full test suite and capture screenshots. … I want very high test coverage.Pasha, to Claude
489tests, all passing
100%of 2,443 lines covered
60screenshots checked
23modules, no libraries
79 Mtokens to build it
~$30at Opus 5.5 prices

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.

The result

The result is a professional solution

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.

One engineA seeded discrete-event simulation: any speed, the same events.
Floor PlanThe room and the kitchen, and who is where.
Process MapActors and resources, tasks with their waiting areas, outcomes.
ScorecardNine numbers for the owner, each against a target.
Pin anythingA task, a resource, one cook, one table, one party.
Measure everythingEvery object has an objective, a target and charts, in the side panel.
What-if actionsCall in sick, break and fix equipment, close a table.
Tested489 tests, every line covered, 60 screenshots.

This is probably not something a business major could do, even with the same AI tools. Better left for a professional software engineer.

The finished Process Map 72 minutes into service at 16x, with Tables selected and their metrics open: 90% in use against a target of at least 70%
The finished Process Map, with the tables selected and their metrics open.

Play with it live Run it yourself View the source

0:00 – 23:34 · The whole conversation

What it took in tokens

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.

KindTokensWhat it is
Re-read from cache425,126,783The 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 input4,562,535Text entering the conversation for the first time: Pasha's messages, tool results, files and screenshots.
Output1,317,248Everything Claude wrote: answers, code, commands and its working notes.
Total431,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

181turns of conversation so far
3views, one engine
23JavaScript modules
489tests, 100% coverage
60reference screenshots
If bought as API calls, with no subscription

What that would cost in dollars

We burned about $148 in tokens to get this done, at the prices of Claude Opus 5.5, the model that ran the session.

ModelRough costNotes
Claude Opus 5.5about $148What we used: $85.03 for cache re-reads, $36.49 for new input, $26.34 for output.
Claude Sonnet 5.5about $116The 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.

Open

What is not done

The conversation that built the page, with Pasha's words as spoken, is in TRANSCRIPT.md.

The series so far

All the episodes

Episode 1: the animated floor plan of the restaurant, busy
Episode 1
The Restaurant An animated, clickable floor plan of a restaurant: twelve tables, waiters, cooks, tickets on a rail and plates on a pass. Built in about an hour, from a spoken description of a real restaurant.

Follow the Episode 1 journey

Episode 2: the service view, with the order rail selected and its metrics open
Episode 2
The Workflow A second view of the same simulation: the work itself, as party states, two queues and the kitchen, with a target and a chart for everything on screen. Found on the fifth attempt.

Follow the Episode 2 journey

Episode X: the Process Map with the tables selected and their metrics open
Episode X · this one
500 Million Tokens to Cook One Process Map The restaurant rebuilt on discrete-event simulation: one engine, three views (Floor Plan, Process Map, Scorecard), objectives and metrics for every object, actions, and a full test suite.

You are here.

Next, Episode 3: building the business metrics out toward the owner's actual objectives.

Thank you for your interest

Want to see more?

There is more from Semantic Works to explore.

See our public projects

Dr. Pavel (Pasha) Simakov
About the author
Dr. Pavel (Pasha) Simakov Managing Partner, Semantic Works LLC linkedin.com/in/pavelsimakov

Happy vibe coding with LLM AI!