Modeling State in Text Adventure Games

11:15 AM - 12:10 PM on July 17, 2016, Room CR5

Katie Silverio

Audience level:
intermediate
Watch:
https://www.youtube.com/watch?v=PdyMwzPSJvk

Description

Although text adventure games, like Colossal Cave Adventure or Zork, don't have graphics, they still have in-game objects to model. I've been working on a framework for writing text adventure games in Python, which means setting on a system for modeling stateful things. In this talk, I'll discuss choosing a design pattern, modifying the pattern to work better in Python, and then use it to make a mini text adventure game!

Abstract

I've been working on a text adventure framework for Python for a few years, and one of the key decisions I've had to make so far is how to model in-game objects. Because I'm making a text adventure framework and not a single text adventure game, I had to settle on a system that would let users create their own arbitrary sets of possible game objects. There are many possible design patterns, and they all have pros and cons. Inheritance can reduce repeated code, but designing inheritance trees for game objects can be hard or impossible. Monolithic classes that can be configured to exhibit various behaviors eliminate the need for an inheritance tree, but result in overly complex and unwieldy code. Fortunately, game designers have thought about this problem, and there's a design pattern called Entity-Component-System (ECS) that decouples behavior from state, making it easy to assemble stateful things with arbitrary sets of behaviors. However, pure ECS does not work well with object orientation, which can make it prohibitively difficult to use. I'll take you behind the scenes of my text adventure and show you how I solved the problem, and then use my framework's state system to set up the stateful objects in a mini text adventure!