The Ghost in the Dungeon Machine
How I used free AI tokens to re-enter my old favorite dungeon
It started the way these things sometimes start: not with a big plan, but with free tokens.
For several weeks I had access to Google Anti Gravity and a decent quota, because I already use my Workspace heavily, post emails there and pay for extra storage. So I suddenly had a lot of AI compute available. I don't actually use Anti Gravity much in daily work, but the question was obvious: what do you do with a stockpile like that when you don't just want to build yet more example apps?
I put it into nostalgia.
More precisely: into the attempt to have The Bard's Tale II reprogrammed as far as possible. To me, this game was never just an old role-playing classic from the eighties. It was one of those games that felt bigger than the screen it ran on. On the C64 the world consisted of a few colors, blocky characters and a great deal of imagination. But in my head, Skara Brae was not small. In my head it was dangerous, dark, confusing, full of secrets.
So I allowed myself not to simply reconstruct the game one-to-one out of nostalgia. I wanted to make the world darker, denser, more threatening. The way it perhaps felt back then, even though the hardware couldn't show it that way.
And at some point the experiment turned into something else. I read up on LLMJEV, a decision model that doesn't produce long texts but makes decisions, scores probabilities and clusters patterns. That suddenly fit a dungeon crawler remarkably well: a game doesn't need a poetic paragraph at every step. It needs a decision.
Do I go forward? Do I turn left? Do I buy this item? Is the party ready for combat? Is this path dangerous?
That is how I ended up with a game that I don't just build, but also watch as it learns.
flowchart TB
A["Autopilot Controller<br/>Game state & telemetry"] --> B["Jev System One<br/>fast decisions"]
A --> C["Spatial exploration<br/>map, frontiers, BFS"]
A --> D["Canonical Truth Engine<br/>1986 rules"]
B --> E["DecisionLearner<br/>memory of successes & failures"]
C --> E
D --> E
E --> F["Next action<br/>move, turn, fight, trade"]
Why a regular language model stumbles in the dungeon
If you ask a large language model for a strategy, you usually get a nice answer. Often even a very convincing one. But a dungeon is not an essay.
A dungeon is tight, fast and mean. One wrong turn is enough and the party walks into a trap. One bad combat move and the mage is dead. One hallucination and the model invents a spell that doesn't exist in the game.
This is where the difference gets interesting. Classic LLMs are autoregressive: they write token by token. That is perfect for prose, but not ideal for an agent that constantly has to make small, hard decisions. Jev works differently. It isn't about explaining at length, but about scoring an option.
Three operators are especially interesting for my Bard's Tale experiment:
- Noul decides in binary: yes or no. Is the party in danger? Is the light still enough? Does anyone need healing?
- Choice picks from fixed options: forward, left, right, attack, spell, defend.
- Score rates states on a scale: risk, readiness, combat strength, exploration value.
That sounds less glamorous than a large language model, but for a game it is often far more valuable. The agent doesn't need to talk well. It needs to survive.
How the machine sees the dungeon
The Bard's Tale II lives on grid logic. Cities and dungeons consist of coordinates. Every tile can be a wall, door, trap, shop, teleporter or dead end. For humans, that adds up to a world. For the agent, it adds up to a state space.
So the AI doesn't just see a pretty picture, but a small, very concrete situation:
- Where is the party standing?
- Which direction is it facing?
- What is ahead, to the left and to the right?
- Which tiles are known?
- Where does the next unknown area begin?
From this information, the exploration algorithm computes the next sensible step.
flowchart TB
U["Unknown tile<br/>frontier target"]:::target
A["(15,18)<br/>known"]
B["(15,17)<br/>known"]
C["(15,16)<br/>known"]
P["(15,15)<br/>Party facing south"]:::party
W["West<br/>new"]:::target
O["East<br/>visited"]:::known
U --> A --> B --> C --> P
W --- P --- O
classDef party fill:#111827,stroke:#f97316,color:#fff,stroke-width:2px;
classDef target fill:#f59e0b,stroke:#92400e,color:#111827,stroke-width:2px;
classDef known fill:#e2e8f0,stroke:#64748b,color:#0f172a;
This kind of perception is what I like most about the project. It isn't spectacular, but it feels right. The agent doesn't play by pretending to be a human. It plays by taking the game seriously.
When the light goes out
One of the harshest rules from the old school of role-playing games is: without light, you are blind.
That feels almost unfamiliar in modern games, because they rarely leave players completely in the lurch. In Bard's Tale, though, darkness is not an atmospheric effect but a rule. When the torch, spell or bard song goes out, the party sees nothing.
I wanted the AI to respect that harshness. So when there is no light source, it doesn't get a comfortable uncertainty value, but a clear sensory limit. Ahead is then not "probably free" but unknown. The score for walking forward blindly collapses. Exploration stops. The system looks for light first.
This is one of the points where the darker version works better for me than a pure nostalgia copy. The old game mechanic suddenly carries weight again. Darkness is not decoration. Darkness is danger.
The ping-pong bug that taught me more than planned
Of course, this didn't run elegantly right away. One of the nicest bugs happened at an intersection in Tangramayne.
The party stood on a tile, saw unknown paths and started turning endlessly. West. South. West. South. Again and again. On paper, the individual decisions were even understandable: unknown paths were attractive, loops were to be avoided, turning seemed better than walking forward. Put together, though, they made a perfect little decision hell.
stateDiagram-v2
[*] --> Blick_Westen
Blick_Westen: Front unknown
Blick_Westen: Left unknown +170
Blick_Westen: Forward penalized -140
Blick_Westen --> Blick_Sueden: TURN_LEFT
Blick_Sueden: Front unknown
Blick_Sueden: Right unknown +170
Blick_Sueden: Forward penalized -140
Blick_Sueden --> Blick_Westen: TURN_RIGHT
The fix wasn't big. That's what I liked about it.
After a turn on the same tile, the direct counter-turn is dampened. If there is a free path ahead, walking forward gets a strong bonus. And if a tile has never been entered, it must not be treated as if it were part of a loop.
This is exactly the kind of engineering I enjoy in projects like this: no huge meta-architecture, just a small rule in the right place.
A memory for good and bad decisions
The most interesting part is the DecisionLearner. It doesn't turn the autopilot into a magical being, but it gives it a memory.
Every decision leaves a trace. When the party enters new territory, the previous move gets a small reward. When it walks the same known road again and again, there is a penalty. When a combat move gets the party into trouble, offensive options lose weight in similar situations.
flowchart LR
A["Action"] --> B["Measure outcome"]
B --> C{"Was it good?"}
C -->|New tile<br/>Fight won| D["+ Bias"]
C -->|Repetition<br/>Took damage| E["- Bias"]
D --> F["Similar situation later"]
E --> F
F --> G["better decision"]
I like that it stays small. It isn't a huge training run, no new model run, no heavy framework. It is more of a game memory: enough to change behavior, but not so much that the system becomes incomprehensible.
What this looks like in the running game is shown in the screencast: the autopilot runs in auto mode, explores, fights and learns step by step as it goes.
Garth's Shoppe and the economics of survival
A dungeon crawler isn't won only in combat. It is also won in the shop.
In Garth's Equipment Shoppe, a different side of the autopilot shows. The AI collects gold, checks equipment, sells dead weight and makes sure the bard doesn't walk around without a usable instrument. The Fire Horn in particular is no small thing in this world, but a life insurance against monster groups.
flowchart TB
A["Enter Garth's Shoppe"] --> B["Pool the party's gold"]
B --> C{"Bard has<br/>at least 2 Fire Horns?"}
C -->|No| D["Buy Fire Horn"]
C -->|Yes| E["Check inventory"]
D --> E
E --> F["Sell junk & duplicates"]
F --> G["Check upgrade for weakest member"]
G --> H["Leave shop"]
Here, too, it matters to me that the system isn't just "AI somehow". It knows the game rules. It knows class restrictions. It knows that a mage shouldn't wear plate armor and that rank 7 in the formation has to stay free, because summoned creatures or Princess Stephanie will need the space later.
Why the rules of 1986 feel modern again
The longer I worked on the project, the more I understood how modern this old strictness actually is.
Many AI demos look impressive as long as nobody checks exactly whether the proposed action is allowed. In a game like Bard's Tale, that shows immediately. An invented spell is not a creative suggestion but an error. A wrong class with the wrong equipment is not a stylistic slip but an invalid state.
That is why a Canonical Truth Engine sits behind the decision model: a rule grid built from the old game rules. Jev may propose. The engine decides whether the proposal is allowed to exist in this world at all.
I now like this combination almost more than pure autonomy:
- a cheap model for fast decisions,
- a clear rule set against hallucinations,
- a spatial memory for orientation,
- a small learner for better habits.
That is not an all-knowing AI. It is more of a specialized dungeon mind.
What I actually value about it
The Bard's Tale II isn't interesting to me merely because it is old. What I value is its uncompromising mix of fantasy and hardness. The game didn't want to be comfortable. It wanted you to draw maps, make mistakes, memorize, fail and come back.
My dark AI version is therefore not an attempt to replace the original. It is more of a conversation with it. What happens when you combine a game from the 8-bit era with today's decision models? What is left of the old feeling? What gets stronger when the machine doesn't just execute but learns?
When I watch today as El Cid carries his Fire Horn, Pip stands protected in the formation and the party slowly pushes into unknown corridors, it is more than a technical experiment to me. It is a strange, beautiful circle: the imagination that used to have to fill the gaps in the C64 graphics now lives inside the system itself.
And somewhere between grid map, rule set and decision model, exactly what grabbed me back then emerges again:
A dark corridor.
A party that isn't really ready.
And the next step forward.