demonstration 4 of 11 · adventure.html

Fact based world visualisation

Ashcombe Hall is a small manor built out of triples. The room view shows exactly what the facts say is there, and nothing else. An auto-player explores it, works out its own goal, and plays toward it.

What it demonstrates

A text adventure is a good test of a fact store, because a room is a claim about what exists. If the picture and the prose disagree, one of them is made up.

Here they cannot disagree, because the picture is computed from the same rows the prose reads. Take the lamp and it leaves the picture. Open the portrait and what was behind it appears.

Three worlds ship: a six room hall with one lock, a three room cottage with none, and a nine room museum with three locks and a deeper chain to work through.

The auto-player is the part worth showing. It is not scripted. One generic marker fact says which object is the objective, and the player works out the rest by exploring, opening what it can, and pathing to what it has found.

Turn on the editor and you can change the facts and watch the room change with them.

Next Chat you can replay

Chat you can replay

The opening text below is the world's own. The commands are assertions from the adventure test file.

The opening, straight out of the world file.

the adventure begins. You are in the study of Ashcombe Hall. Somewhere in this house is a letter meant for you. Say "look" to look around, "go north" (or south, east, west, up, down) to move, and "stop playing" to end the game.

The first line of corpus/worlds/src/ashcombe-hall.jsonl, the world's hand-authored source file.

Two ordinary commands. Taking a thing and moving a room.

tmct> take the lamp
you take the lamp.
tmct> go north
you go north. Now in the library.

Asserted in test/services/adventure.test.mjs.

The full run to the win condition, fourteen turns, asserted end to end.

tmct> play ashcombe hall
tmct> look
tmct> go north
tmct> go north
tmct> look
tmct> take the portrait
tmct> open the portrait
tmct> take the key
tmct> go south
tmct> look
tmct> go south
tmct> unlock the cabinet with the key
tmct> open the cabinet
tmct> take the letter
you take the letter

Asserted in test/services/adventure.test.mjs, which runs the whole sequence and checks the final turn lands the win.

The house has its own inhabitants. The housekeeper moves on a schedule, and her move is a real fact written into the world.

at turn 3: housekeeper@turn3  mgx:currently-in  library
the housekeeper walks in.

Asserted in test/services/adventure.test.mjs. The narration and the fact are written by the same pass.

Next What it looks like

What it looks like

A room drawn from its facts, with the map and what you are carrying alongside.

The tmct adventure page showing a room of Ashcombe Hall drawn from its facts with the map and satchel alongside
adventure.html. One room of Ashcombe Hall, drawn from the rows that describe it.
Next What it works out

What it works out

Where the room comes from. The world is a list of triples. Every turn folds them into a current state, ranking each subject's newest placement, position and openness by epoch and turn. History is kept; the fold decides what is true now.

  • lamp mgx:located-in study
  • key mgx:hidden-in portrait
  • study mgx:has-exit-north library
  • cabinet mgx:unlocks-with key
  • letter mgx:is-objective true

What gets drawn. Each object resolves to a visible room or to nothing. A room is itself. A placed object is in its room. An object one hop inside an open container is in that container's room. Anything hidden, carried, or inside a closed container resolves to nothing and is not drawn.

That rule is the whole demonstration. There is no separate render list to keep in step with the prose. Close the cabinet and the letter stops resolving, so it stops being drawn.

Where it sits in the room. Stacking comes from the current on-top-of and on-plane rows if there are any. Failing that, the object's class default is found by walking up the class hierarchy. Failing that, the floor.

What you can do. The available commands are computed from the facts too: one go per exit, and an unlock, open, examine, talk or take per visible object, based on the predicates that object actually has.

How the auto-player decides. It reasons over exposed facts only: rooms it has actually visited, plus its own facts, plus the objective marker. Then it takes the first rung that applies. Win if it already carries the objective. Path to the objective's room if it knows where that is. Work an exposed container, unlocking it with something it carries or can fetch. Explore an exit it has not been through. Path toward the nearest room with one. Otherwise say plainly that it has stalled.

How it paths. The same bounded search the Hanoi page uses. The edge function is built from exposed exits only, so the planner cannot route through a door the player has never seen.

Next How it is built

How it is built

corpus/worlds/src/ashcombe-hall.jsonl is hand-authored: facts, rules and an opening line. npm run gen:worlds-pack compiles it into a gzipped shard.

src/adapters/corpus/worlds-pack.mjs reads it in Node and materialises class-default contents. The site build embeds the resulting payload into the page.

src/domain/adventure.mjs is the turn engine: the state fold, the command runner, the digest sentences, the affordance list and the NPC pass. src/domain/adventure-autoplay.mjs is the auto-player. src/domain/planning.mjs is the search.

src/services/adventure-viz.mjs renders the page and computes the scene from the fold. Sprites resolve through src/domain/sprite-map.mjs, the same resolver the sprite library documents.

Commands are parsed by src/domain/grammar/ace.mjs, the controlled English parser, not by a keyword list.

Next Related work

Related work

A world model that renders itself, and an agent that finds its own goal in it.

  • W3C, RDF 1.1 Semantics, Recommendation, 25 February 2014.The room is a set of triples. This is what saying one commits you to.
  • W3C, OWL 2 Primer, Recommendation, 11 December 2012.The class hierarchy behind default placement and sprite resolution.
  • Fikes and Nilsson, “STRIPS”, Artificial Intelligence 2(3–4), 1971.Actions as add and delete effects on a state. Taking the lamp is exactly that.
  • Ghallab, Nau and Traverso, Automated Planning and Acting, 2016.The plan-act-replan loop the auto-player runs each tick.
  • Molineaux, Klenk and Aha, on goal driven autonomy, 2010; Cox, “Perpetual Self-Aware Cognitive Agents”, AI Magazine 28(1), 2007.Picking a goal rather than being given one, and noticing when the current one has stopped working.
  • Jensen et al., “A Consensus Glossary of Temporal Database Concepts”, SIGMOD Record 23(1), 1994.The vocabulary for the epoch-and-turn stamps the state fold ranks by.
  • Attempto Controlled English, ACE 6.7, 2013.The controlled English the commands are parsed as.
  • Reiter, “On Closed World Data Bases”, in Logic and Data Bases, Plenum, 1978.A room the player has not visited is unknown, not empty. That distinction is what the exposed-facts filter enforces.
Next Credits and further reading

Credits and further reading

Where to look next.

Back to all seven demos