Saturday, 5 July 2025

Creating our own map and language parser

A-level Computing: learning how to create our own adventure game - creating a map of the rooms and creating our own language parser, using Zork as a model. Learning about writing the descriptions of what you see so the player can visualise the scenario.

A-Level Computing: Create Your Own Adventure Game – Maps, Parsers, and Imagination

There’s something magical about the old text-based adventure games of the 1980s. Before 3D graphics, open-world engines, and ray-traced shadows, all you needed was a keyboard and your imagination. Games like Zork, Adventureland, and The Hobbit were immersive not because of what you saw, but because of what you read. In today’s A-Level Computing lesson, we’re stepping back into that world—not just to play these games, but to build our own.

Let’s go on an adventure in programming, logic, storytelling—and a bit of creative flair.


๐Ÿ—บ️ Step One: Creating the Map

Before any coding begins, every adventure game needs a map—a layout of interconnected rooms, each with its own description, objects, and potential dangers.

Students begin by sketching out a grid or flowchart. Each room should have:

  • A unique name (e.g., Dark Cave, Enchanted Forest, Abandoned Library)

  • Descriptive text to set the scene

  • A list of exits (e.g., north, east, upstairs) and where they lead

  • Any items or puzzles located in the room

Here’s an example:

Room: Mouldy Kitchen
The smell of rotting onions clings to the air. A flickering lightbulb reveals a crusty sink and an open door to the north.
Exits: North → Dining Room
Items: Rusty Key

This planning step builds understanding of graph structures in computer science. Each room is a node, and each exit is an edge. Drawing the map helps students visualise how data structures and logic combine to make a world.



๐Ÿ’ฌ Step Two: Building the Parser – Teaching the Game to Understand You

One of the most iconic parts of Zork and its peers was the language interface. You typed something like:

GET LANTERN
GO NORTH
OPEN DOOR WITH KEY

And the game responded. Behind the scenes, the game used a parser—a small program that breaks down the player's input into a format the game can understand.

This is where our A-Level computing skills shine. Students learn to write a basic parser that:

  1. Splits the input into individual words.

  2. Identifies the verb (e.g., GOGETUSE).

  3. Identifies the noun or object (e.g., LANTERNKEYDOOR).

  4. Matches the input to a known command in a structured list.

  5. Returns a logical response or triggers an event.

We may start with simple commands—two-word sentences—before introducing command patterns with prepositions and conditions. This is a great opportunity to explore string manipulationlistsdictionaries, and state management.


๐ŸŽจ Step Three: Writing Descriptions That Spark the Imagination

Here's where computing meets creative writing. You can’t rely on photorealistic graphics to show what the player sees—you have to describe it well enough that they can see it in their head.

Students are encouraged to practise descriptive writing with attention to sensory detail:

  • What can you see? (A tattered banner hangs from the rafters...)

  • What can you hear? (...the soft patter of dripping water echoes from the east.)

  • What can you smell? (...an acrid, metallic scent fills your nostrils.)

  • What can you feel? (...the walls are damp and slimy to the touch.)

This element of the game helps players get immersed, but also improves narrative design and develops empathy with how users (players) interact with a system—a key component of good UX design.


๐Ÿง  Why This Project Matters in A-Level Computing

This isn’t just nostalgia. Creating a text adventure game helps students:

  • Understand data structures (maps, objects, player state)

  • Use procedural logic and conditionals

  • Manipulate strings and arrays

  • Write code that is both functional and creative

  • Learn about user interaction and error handling

  • See the connection between language and logic

And perhaps most importantly—it’s fun. Watching students test their games, tweak room descriptions, or argue over whether "GO IN" should work as a command is proof that learning can be both serious and playful.


๐Ÿš€ Going Further

For students who want to level up their adventure game, why not:

  • Add a simple inventory system

  • Introduce NPCs with dialogue trees

  • Create puzzles that require items and actions in the right sequence

  • Store and load the game state using files

  • Convert the game to run on a web browser using Python and Flask, or JavaScript

You could even look at how modern Interactive Fiction engines (like Inform 7 or Twine) structure language and gameplay.


๐Ÿงพ Final Thought

In a world obsessed with cutting-edge graphics and high frame rates, there’s something deeply satisfying about building a world with nothing more than text and logic. The skills involved—both technical and creative—are highly relevant to modern software development, from writing game engines to building conversational interfaces or AI systems.

So next time your student types LOOK AROUND and gets back a wall of vivid description, just remember: they didn’t just play the game. They built it.


 

No comments:

Post a Comment

Is It Possible to Teach and Develop Augmented Reality (AR)?

  Is It Possible to Teach and Develop Augmented Reality (AR)? A Level Computing Augmented Reality (AR) is no longer a futuristic idea. It i...