As I’ve said in some of my previous posts, I’m a puzzle solver at heart. Even my career as a software developer (and now in application security) is centered around it. I love to try and figure out how things tick and what I can glean from those mysteries. While I don’t write as much code in my day-to-day work, I am still in investigation mode. Part of my role is to figure out what might break and how to best protect a piece of software. It’s easy to get down in the weeds and look up only to find you’re neck deep in tech that you may not be as familiar with. This is when the puzzler in me kicks in and I start into learning mode.

Why Python?

In my current role, I’ve been using more Python than I have in previous jobs. I was familiar with the basics but I hadn’t really dug into the language and its ecosystem. There was some chance for me to work on these skills on the job, but to really be able to understand a language, I find that doing is better than just reading any day. So, I needed a project I could use to improve my Python skills that was interesting enough to keep me motivated to learn more. I looked at several sample projects and some of the basic “getting started” project ideas, but they didn’t seem like they’d hold much interest past the first bit. I started thinking about other things I enjoyed and how I might be able to marry those with this desire to learn.

Then, in poking around the web one day, I was reading about Python games on Reddit and someone made the suggestion (to someone else) to create a text-based game as a way to more thoroughly learn the language. It was perfect – not only did it provide a good way to learn the language but it also would allow me to incorporate one of my other passions: escape rooms.

Escaping with Adventurelib

I decided that, while I could probably hack through a simple text-based game structure, it might be better to start with a good base and work up. I spent some time searching and came across the Adventurelib Python library. This library is designed to set up some of the boilerplate code to help you get started quickly and easily with building a text-based adventure game. It’s even designed to be used in a teaching setting. It only provides the basics (rooms, items, actions, etc) to build on top of but it’s easy to extend.

Now that I had my tools selected, all I needed was something to build with them. I thought about coming up with a custom room and wild ideas for puzzles filled my head. I quickly realized that trying to do this, level up my Python skills and learn all about the Adventurelib library was a bit much to tackle all at once. So, what was the next best thing? I could always reproduce a part of one of the escape room games I’d played on my tablet. Some of those didn’t exactly have the depth I wanted though…what to do? Then I remembered a potential source.

Escape This Podcast to the Rescue

In searching around for other podcasts to listen to related to escape rooms (shoutout to the excellent Room Escape Divas here, my first ER-related listen), I came across Escape This Podcast with hosts Dani and Bill. I loved the format, getting to listen to random guests puzzle through different rooms that Dani had created just for the show. I also remembered that, as a generous gift to the ER community, she provided the full documentation for those rooms – puzzles, solutions and all.

At the time I had just listened to Episode #3 in their newest series, the “Descent of the Cullodens” series: “I’d Kill You if I Had My Gun!” and decided that was as good a place as any to start. It was perfect, and a short approval email response from Bill later asking about using the content, I was off and running. I had my language to learn, the library to use in learning it and the full structure of the room to build out!

Enter the Game

With all of this laid out, I dove right into creating the game. Adventurelib makes this super simple, fortunately, and has some excellent documentation to help get you started. To help out others that might be interested in creating something similar, I’m going to write a series of posts on my process of getting the game up and running, design decisions I’ve had to make so far and some of the challenges I’ve faced.

First, though, let’s get a simple game up and running. We need to install the Adventurelib library first before we can use it. This can be accomplished using the pip Python package installer by running this on the command line:

pip install adventurelib

Once that’s installed, creating a game with a single room is super simple. Create a new file (name it something like game.py) and put the following inside:

from adventurelib import *

@when("look")
def look():
    print("You look around and don't see much of anything")

start()

This can then be run using the Python command line:

python game.py

When executed, you should just be dropped at a “>” prompt. If you type in “look” and hit enter, you’ll be greeted with the “You look around…” message. To exit out of the game, just type “quit” and hit enter. In the code above, “look” is a command and allows you a flexible way to parse what the user enters and handle it accordingly.

Simple, right? I know for non-programming types it seems like I’ve skipped a lot of steps out there with information on setting up Python and the basics of the language, but there are tons of other sites out there to explain some of those.

Moving Right Along

I’ve been working on this project for a few weeks now with some varying levels of success along the way. There have been a few places where I’ve gotten stuck, but it’s definitely off to a good start. Stay tuned for more progress and helpful hints!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s