Interactive Fiction in Python Introduction
"You are in a maze of twisty little passages, all alike..." As a middle school student with a love of reading and an active imagination, the words on the screen conjured up visions of monsters, treasure, and danger...all with just a little text. Interactive Fiction was once a hugely popular genre of computer games, but is now relegated mostly to hobbyists. Since I am teaching a new Python course this year, I wanted to learn more about Python myself and make something fun at the same time. So I settled on making my own interactive fiction game.
For those of you unfamiliar with the game mechanics of Interactive Fiction, users enter simple English commands to guide a character through a virtual world. The goals vary, but by the end you've faced numerous challenges and probably died...many, many times.
Here is the opening of Zork I The Great Underground Empire, one of the most famous text adventures of all time. The ">" symbol shows where the user typed a command.:
You are in an open field west of a big white house with a boarded front door.
There is a small mailbox here.
> open mailbox
Opening the mailbox reveals:
> read leaflet
Welcome to Zork (originally Dungeon)!
Dungeon is a game of adventure, danger, and low cunning. In it
you will explore some of the most amazing territory ever seen by mortal
man. Hardened adventurers have run screaming from the terrors contained
As you've likely noticed, you are able to interact in this world in logical ways. First, there's a mailbox...let's open it. A leaflet? Let's read it. And so on... Older Interactive Fiction, such as Zork, accepted two word commands (and a few shorter ones such as inv for inventory. The player can get items in the game, drop them, and use them in various ways. Like reading a book, you use your imagination to visualize the scene. In this game as with most interactive fiction, you move around the world by using north, south, east, west, up, or down. The user needs creativity, perseverance, and logic to solve the puzzles encountered in the game.
Stay tuned for more installments as I walk you through the coding process and teach some Python concepts along the way! UPDATE: Click here to read Part I.
Recent blog posts
- Simple Python Game Tutorial Using Classes
- Video Tutorial: Python Spacewar Game
- Video Tutorial: Python To-Do-List (GUI Version)
- Video Tutorial: Simple Space Invaders Clone
- Video Tutorial: Python Functions with Turtle Graphics
- Video Tutorial: Python Guessing Game (GUI Version)
- Global Codeathon Scratch Tutorials
- Video Tutorial: A Simple Python Turtle Graphics Game
- Video Tutorial: Tic-Tac-Toe in Python
- In Favor of Standardization in Ed Tech