In this homework assignment, you will write your own classic text adventure game. You will implement two text adventure games. One will be a re-implementation of the Action Castle game, and one will be a game that you design yourself. The game that you design can be on any topic, or can tell any story of your choice. We will play the games that you design during class, and part of your grade will be awarded based on how creative/exciting your classmates think your game is.
We have provided starter code for a basic text adventure game. I recommend using Visual Studio Code for this homework.
First download the zip file (or git clone https://github.com/pearls-lab/ai-agents-course.git
), then create a virtual environment and install
the dependencies.
$ unzip hw1.zip
$ cd part-1-textgame
$ python3 -mvenv venv
$ source venv/bin/activate
(venv) $ pip install -r requirements.txt
We recommend that you use VSCode. The best way to ensure a good experience with VSCode is to launch it from the project directory with your virtual environment already enabled.
$ cd path/to/homework/HW1/
$ source venv/bin/activate
(venv) $ code .
If the code
command does not work, open VSCode’s command pallet (command+shift+p)
and type shell command
. VSCode should then show an option for installing
‘code’ in your PATH.
After you have downloaded the code, started your virutal envionment and launched VSCode, you should work through the HW1_Tutorial.ipynb
notebook that we created to show off the basics of our text adventure game platform. Here’s a screenshot of the notebook that you’ll see.
Our starter code includes a vizualize tool text_adventure_games.viz
which will allow you to view your game map as a directed graph. To use this, you will also need to install graphviz. There is both the graphviz app and the graphviz python library, which is a wrapper for the app. You can find instructions on how to install graphviz from their website here: graphviz.org/download/
Action Castle is a game by Jared A. Sorensen. It is included in his book Parsley, which is a collection of games inspired by the text-adventures of the 1980s. Parsley is a party game where you take on the role of the parser, and the players shout out commands like GO NORTH, LIGHT LAMP or GET SWORD. You obtusely follow player’s commands, simulating a computer’s limited vocabulary. The effect is suprisingly hilarious and fun.
You should download “Parsely: Preview n’ Play Edition” which is free on Jared’s website. It contains the Action Castle game that you’ll be implementing. You can also buy the full Parsley book for $20 if you’d like to support an awesome indy game developer. The Preview n’ Play Edition also explains how these kinds of games work.
We have implemented most of Action Castle for you.
Need a hint on how to get started? Check out the Troll_Block
class to see an example of how to implement a Block, and the Eat
class as an example of how to implement an Action.
Want to know how to win the game? Here’s a sequence of actions that should result in a winning state, if you’ve implemented the game correctly. You can play through the full Action Castle game with the following commands:
take pole, go out, go south, catch fish with pole, go north, pick rose, smell rose, go north, go up, get branch, go down, go east, give the troll the fish, go east, hit guard with branch, get key, go east, get candle, go west, go down, light lamp, go down, light candle, read runes, get crown, go up, go up, go up, unlock door, go up, give rose to the princess, propose to the princess, wear crown, down, down, east, east, sit on throne
Your game should include all of the following:
A fun example of a tiny game with very 3 locations and 3 items is the “Flaming Goat” game in Jared A. Sorensen’s Parsley book.
Optionally, you can think about adding other elements to your game, like:
Feel free to modify the starter code (Text_Adventure_Game.ipynb
) in any way you see fit in order to enable your game ideas. However, the “Play the game” and “Visualize your game” code blocks should remain functional.
What kind of game should you make? It’s up to you! Be creative! For inspiration, we recommend searching Pinterest for cross-section maps. Here are some that we like:
Tip: I recommend drawing out on your game on graph paper before you get started.
Submissions should be done on Gradescope.
Submit an IPython notebook called action_castle.ipynb
that runs Action Castle to “HW 1 - Part 1 Action Castle”. This assignment will be automatically graded.
Submit 4 files to “HW 1 - Part 1 My game”
my_game.ipynb
that runs the initial version of your game.playthrough.txt
with all of the commands that we need to issue to complete your game. It should be a plain text file with one command per line.README.md
containing a short paragraph describing your game, and why you picked that topic.Do not zip or compress your files! Submit them as individual files.
Chris Ainsley / Adventuron Software Limited, Adventuron Classroom. This is a tutorial aimed at teaching elementary school kids how to program by writing a text adventure game. I modeled our text adventure game after this Adventuron system.
The Hitchhiker’s Guide to the Galaxy (H2G2), How to Make a Text-Based Adventure - Commands and Parser.