The Hobbit for the 48K ZX Spectrum was released in 1982. I was nine years old. I didn’t have a job, so I can only presume my parents bought the game for me or I pirated a rich friend’s cassette tape. Games were expensive, relatively speaking, in the early eighties!

While I look back fondly on these classic games, one overriding memory I have of all Spectrum titles I owned (or pirated) is that I never completed any of them, least of all The Hobbit. It was hard, and there were no YouTube walkthroughs back in the day.

And yet, I was utterly captivated (and frequently amused) by the NPCs. Characters like Thorin and Gandalf had a life of their own: they wandered between rooms, got into fights, sat down, got frustrated, and did things whether you typed anything or not. “Thorin sits down and starts singing about gold” is probably the most enduring memory for many people who played it.

I didn’t fully appreciate the technical achievement at the time. It had cutting-edge natural language parsing (Inglish), real-time simulation, and a physical object hierarchy. Reading about it years later on Wikipedia, it is clear how revolutionary Philip Mitchell and Veronika Megler’s design was, and that the entire world, vocabulary, physics engine, and AI were squeezed into just 48 kilobytes of memory!

In the spirit of the retro terminal aesthetic on this site, I teamed up with Claude and Gemini to build Barrow Delve (also known as The Sun Metal Crown), a mini text-based adventure you can play directly on the blog homepage.

Here is how we built it, how the systems interact, and what it took to bring 1982-style emergent simulation to modern vanilla JavaScript.


1. The Inglish Parser: Beyond “Verb Noun”

Most classic adventure games of the late seventies and eighties used rigid two-word parsers (GET LAMP, GO NORTH). The Hobbit completely changed all that with Inglish, an advanced natural language parser capable of processing complex grammatical clauses, pronouns, adverbs, and multi-noun actions.

In Barrow Delve, we recreated that rich conversational grammar:

> pick up the crown and give it to sella

Chaining, Punctuation & Early Termination

The engine breaks compound sentences on AND, THEN, commas, semicolons, and full stops. Crucially, clauses are evaluated lazily against the live, updating world state. If an action in the middle of a chain fails—such as reaching for a non-existent item or bumping into a locked door—the engine immediately halts execution with a contextual failure message rather than blindly executing subsequent steps.

Multi-Noun Decomposition

Commands with lists of objects automatically decompose into sequential actions with individual physics and encumbrance checks:

  • take chalice, sack and ivory box → resolves three discrete pickup attempts.
  • drop torch and tinderbox → handles multiple item drops gracefully.
  • give torc, ring and chalice to sella → processes individual transfers to your companion.

Contextual Pronouns & Elliptical Clauses

The parser maintains anaphoric memory (lastObj). If you type:

> take ring and give to sella

The second clause detects an elided direct object, looks back at the ring you just grabbed, and automatically resolves it to give [the ring] to Sella.

Companion Directives & Coordinated Dual Strikes

You can order companions directly:

> sella, take mask and go up

Even better, we engineered a coordinated combat strike. If you type:

> attack corm and sella, attack corm

The engine recognises a simultaneous strike on the same target. Both the player’s blow and Sella’s strike land in the same turn tick. If your combined strength slays the rival before their initiative phase, the enemy goes down before they can retaliate!


2. Mass and Physicality

In Barrow Delve, inventory isn’t a magical bottomless bag; everything has physical mass, weight, and volume.

Recursive Encumbrance

A container’s total weight includes everything packed inside it and carrying heavy loads impacts gameplay dynamically:

  • Combat Slowdown: Heavy carried mass slows your swing, reducing effective damage output and triggering encumbered combat feedback.
  • Stealth Penalties: Sella will warn you if your load is too noisy. Sneaking across loose gravel with an armful of clattering metal is an easy way to alert the lurking monster!

Directional Throwing Physics

Items can be hurled in any direction through room exits:

> throw torch down

Throwing a lit torch down a flight of stairs extinguishes the flame on impact, sending it into the room below. Throwing a heavy object directly at an NPC deals damage proportional to the item’s mass.


3. Autonomous NPCs: Regard, Scent & False Beliefs

The magic of The Hobbit was that NPCs were autonomous agents, not static dialogue trees waiting for player prompts. We built Barrow Delve around the same philosophy.

Sella: Loyalty, Greed and Regard

Sella the thief has her own personality and internal state:

  • The Regard Meter: Her opinion of you shifts dynamically based on your behaviour. Sharing loot, lighting dark corridors, and asking her about dungeon lore improves her regard. Striking her, asking unreasonable favours, or repeatedly demanding items back damages it.
  • Greed & Departure: If Sella is carrying enough gold to satisfy her greed threshold, and her regard for you drops too low, she won’t stay to help you, instead she will turn on her heel and walk out towards the moor on her own.
  • Refusal & Shrugging: If ordered to do something dangerous while unmotivated, Sella looks at you and shrugs. Push her too far, and she will leave permanently.

Epistemic State & False Beliefs

NPCs maintain their own knowledge bases (me.knows). Sella only knows about a treasure if she was in the room when it was revealed. If you open a casket, take a silver ring, and shut it again while she is elsewhere, Sella genuinely believes the ring is still in the casket and will investigate an empty box.

The Blind Bone-Hound & The Sensory Bus

The bone-hound roaming the lower warrens is completely blind; torches and darkness mean nothing to it. Instead, the game engine runs an acoustic event bus.

Every footstep, dropped item, picked lock, and trap trigger broadcasts a noise event tagged with a decibel radius. A sneaking player generates zero noise, allowing you to slip past the beast unnoticed—provided you aren’t carrying a clattering armful of loot.

Multi-Target Retaliation

When combat breaks out, enemies aren’t hardcoded to focus solely on the player. If Sella attacks Corm or the hound, the enemy retaliates directly against her. If both the player and Sella attack an enemy simultaneously, the monster dynamically splits its retaliation 50/50 between both combatants.


4. The Magic of Emergence

The beauty of building an adventure game on physical rules, sensory buses, and autonomous goals is that narratives emerge naturally without being explicitly scripted.

During playtesting, we encountered scenarios no single if/else statement was written to handle:

  • A player dropped a burning torch into a lower shaft, alerting Corm, who wandered over to investigate the noise and was promptly killed by the bone hound.
  • Sella was caught by the wight because she lingered to pocket loot after being insulted by the player.

For me, these unscripted events are the most fascinating aspect of this parser/world model.

Does it fit into 48K?

The raw javascript source code with comments comes in at 118KB. In 1982, The Hobbit achieved its 48K miracle because of Huffman Text Compression (English letters were compressed into variable 4-6 bit codes instead of fixed 8-bit bytes.), tokenised verb tables and a custom z-machine interpreter. If Barrow Delve were compiled to native Z80 assembly with Huffman-compressed text tables, it would easily sit inside 48K!

Building Barrow Delve was a fantastic reminder of how much fun (and surprising depth) can be unlocked by treating the game world as a living simulation rather than a static decision tree. Sure, you could play an AI driven adventure and literally do anything, but that’s kind of boring. I like the constraints inherent in parser driven games with simple world mechanics, because playing the game is like solving a puzzle (and I love solving puzzles!).

Give it a try on the blog page and see if you and Sella can make it out onto the heather alive with the Sun Metal Crown!

← back to blog index