Skip to content

Instantly share code, notes, and snippets.

@peteristhegreat
Created February 24, 2026 19:20
Show Gist options
  • Select an option

  • Save peteristhegreat/e00c5d1383f0d3e0fa902aa652e46104 to your computer and use it in GitHub Desktop.

Select an option

Save peteristhegreat/e00c5d1383f0d3e0fa902aa652e46104 to your computer and use it in GitHub Desktop.
Interactive Fiction: From Caves to Code

Interactive Fiction: From Caves to Code

A short walk through the roots of Interactive Fiction (IF), how it evolved, and how to build your own.


Table of Contents


Interactive Fiction (IF)

Colossal Cave Adventure

Colossal Cave Adventure

Image

Image

Image

Image

Often considered the first widely known text adventure (1976). Inspired by real cave systems.

Different versions

  • Original Fortran version (Crowther/Woods)
  • BSD / UNIX ports
  • Modern C ports
  • Recent 3D reimagining (2023)

Is it the first? Not strictly. But it defined the genre.

Modern links


Zork I, II, III

Zork

Image

Image

Image

Image

Originally developed on MIT mainframes.

  • Zork I: The Great Underground Empire
  • Zork II: The Wizard of Frobozz
  • Zork III: The Dungeon Master

Parser-based. More sophisticated language understanding than Adventure.

Playable online:


Infocom

Infocom

Commercialized IF in the late 70s/80s.

Major titles:

  • Planetfall
  • The Hitchhiker's Guide to the Galaxy
  • A Mind Forever Voyaging

Portable via the Z-machine. Ran everywhere.


Core Mechanics

Text-based Everything described. No graphics required.

Cardinal directions

N, S, E, W, U, D
NW, NE, SW, SE

Rooms form a graph.

Inventory gating

  • Treasures
  • Keys
  • Lamp
  • Batteries

Point systems

  • Score
  • Turn count

Save / Load Essential for puzzle-heavy design.

Metroidvania pattern Lock progression behind:

  • Keys
  • Abilities
  • Items

Backtracking is core.


Mazes in IF

Classic trope.

Types:

  • Identical-room maze
  • Direction-randomizing maze
  • Logic-based maze

Zork’s “Maze of Twisty Little Passages” is canonical.


Instead IF Engine

INSTEAD

Image

Image

Image

Image

Hybrid: text + minimal graphics.

Features

  • Lua-based scripting
  • Extremely flexible object model
  • Supports nonlinear narrative

Docs

Primarily Russian community, partial English docs.

Android


Point-and-Click Adventures

Evolution of IF with graphics + mouse.

Image

Image

Image

Image

Major publishers & games:

  • Sierra On-Line

    • King's Quest
    • Space Quest (Roger Wilco)
  • The Secret of Monkey Island

  • Indiana Jones and the Fate of Atlantis

  • Myst

Parser → Verb menu → Point-and-click → Environmental puzzle.


Rogue and Roguelikes (TUI)

Rogue

Image

Image

Image

Image

Another exploration model:

  • ASCII map
  • Turn-based
  • Procedural generation
  • Permadeath

Descendants:

  • NetHack
  • ADOM

Still cardinal directions. Still caves. Different abstraction.


Writing IF in Python

Modern tools:

Basic approach:

  • Model rooms as graph
  • Inventory as set
  • Command parser
  • State machine

Good tutorials:


Writing Your Own IF Engine in Python

Minimal architecture:

Game
 ├── Rooms (dict)
 ├── Player
 ├── Items
 ├── Parser
 └── Event system

JSON-driven world?

Example:

{
  "rooms": {
    "cave_entrance": {
      "description": "You are at the mouth of a cave.",
      "exits": { "north": "dark_tunnel" },
      "items": ["lamp"]
    }
  }
}

Pros:

  • Easy to extend
  • Data-driven
  • Mod-friendly

Alternatives:

  • YAML
  • Embedded DSL
  • Python decorators

Features to include

  • Verb–noun parser
  • Synonyms
  • Conditional exits
  • Flags
  • Trigger system
  • Save/load serialization
  • Scripting hooks
  • Scoring module
  • Hint system
  • Deterministic + seeded randomness

Optional:

  • Undo
  • Transcript logging
  • Unit tests for puzzles

Interactive Fiction is still alive. Minimal UI. Maximum imagination.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment