Building a text-based game
Exploring an old genre for new purposes
June 20, 2023 (updated May 1, 2024) Ā· Felipe Vogel Ā·- What are text-based games?
- Trying out the sub-genres
- So what game do I want to make?
- Appendix A: writing text-based games in Ruby
- Appendix B: Answering my inner critic
UPDATE: To see the beginnings of the actual project that I envision here, see my follow-up post Building a text-based game in Ruby, part 1.
Iāve been mulling over ideas for my next hobby project, now that Iām almost done making my CSV reading log parser.
Iāve decided on (drumrollā¦) a text-based game!
What, seriously? Isnāt that the quintessential newbie project for first-time coders?
Thatās what the critical voice in my head keeps saying. So in this post Iāll dive into the rich and intriguing world of text-based games to convince myself that making one is not, in fact, a dumb idea. In an appendix below Iāve more directly answered my inner critic and its suggestions of more āseriousā projects.
What are text-based games?
For the sake of simplicity, under this one heading of ātext-based gamesā Iām lumping together various overlapping sub-genres, including these:
- Interactive fiction (hereafter āIFā) is the most popular type of text-based game today, with a lively community centered around annual competitions (e.g. IFComp, XYZZY Awards), the IF Community Forum, and IFDB, just to name a few places. IF is an amalgamation of different forms, such as:
- Parser-based IF, in which the player types commands like
north
orexamine sign
. - Hypertext IF, which is a branching narrative navigated via links interspersed within the text. Hypertext IF often feels less like playing a game, and more like reading a short story or poem.
- Choice-based IF is a kind of hypertext IF in which narrative branches are shown at the end of text nodes, just like in the old Choose Your Own Adventure books.
- Parser-based IF, in which the player types commands like
- Text adventures are an older name for parser-based IF. Puzzles were a bigger element than in contemporary parser-based IF, where story more often takes center stage.
- MUDs are essentially MMORPGs but with text and a parser instead of graphics. In fact, MMORPGs are the direct successor to MUDs, and pretty much replaced them.
- Procedural text-based games have little or no authored story, but are more replayable. Roguelikes are a well-known example, though theyāre arguably graphical rather than text-based.
Trying out the sub-genres
Until recently, Iād only ever tried a few IF titles, so now Iām making a renewed effort to explore IF and appreciate it as much as I can. Here are my impressions, along with some examples.
Parser-based IF feels more game-like on the whole, with its clear concept of spaces to be explored. It can be hard for a newcomer to learn, but thatās not a problem if a good tutorial is included (Blue Lacuna, The Dreamhold, Counterfeit Monkey) or if the commands are very intuitive based on context (FeedVid Live).
Hypertext and choice-based IF have a simpler UI (just links) but are extremely varied thematically, covering the spectrum from popular fiction (A Tale of Crowns) to avant-garde (many of Porpentineās games), from comical (You Will Select a Decision) to touching Digital: A Love Story to heartbreaking (Hana Feels).
MUDs areā¦ hard to get into. They seem to have evolved less over the decades than the other sub-genres Iām exploring. Which is great if you got into MUDs in the 1980s, but to me (a tired 30-something new parent in the 2020s) itās too much of a time commitment to learn how to enjoy MUDs. So Iāll leave it at that.
Procedural text-based games are easier fun, being more like graphical games than IF is, and (classic roguelikes aside) being simpler than MUDs. Common settings include medieval fantasy (most roguelikes, Warsim) and space exploration (Seedship, Voyageur).
As an aside, commercial IF has seen an uptick in the past ten or fifteen years from studios such as A Sharp, Choice of Games, inkle, and Failbetter Games, as well as solo creators.
For the most part, I was able to better appreciate text-based games this time around. Still, I didnāt come across any that are quite like the game I want to make.
So what game do I want to make?
Essentially, a game with more world simulation than what is typical in contemporary interactive fiction.
Iāll start by pointing to a few inspiring games that I want mine to be like in spirit, even if some of these are more graphical than what Iām aiming for.
- Dwarf Fortress because it offers nearly limitless creative possibilities in the quest for survival (as well as lots of ways to die). Iām also impressed by the procedural world generation and the insane level of detail in the world simulation, which makes some of the gameās bugs pretty entertaining to read about.
- Kenshi is graphical but itās otherwise similar to the sandbox survival aspect that I have in mind. Some other open-world games (Elder Scrolls, Mount and Blade) are closer thematically to what Iām aiming for, but they emphasize combat to the exclusion of much else, and their worlds are not as changeable or sandbox-like.
- Upheaval is an in-progress ātext-based fantasy roleplaying adventure sandboxā, basically a big world with a non-linear story presented just through text menus. Itās something like the blend that Iām going for, though itās a bit more narrative-driven. (It probably belongs with the interactive fiction examples above.) Hereās a glimpse at the gameplay, and a complete playthrough.
- The Hobbit is a 1982 text adventure that I discovered in the book 50 Years of Text Games. The Hobbit is an attempt at an authored story within a simulation, similar to what Iām aiming for. The results can beā¦ surprising. Players have gone off script by killing Smaug using Gollumās corpse, or by picking up Elrond and carrying him around for a free and inexhaustible supply of Elven lunches. NPCs can also act unpredictably: Gandalf is liable to go off and get killed somewhere, and Bard the Bowman, upon the playerās asking him to slay Smaug, might just say āNoā before being promptly roasted by the dragon. In the words of the gameās main creator, Veronika Megler: āI was really aiming for something like life where the outcome is the result of many independent occurrences and decisions by many people, and sometimes things just donāt work out. [ā¦] I actively wanted the unpredictability.ā The Hobbit was unique, and it still is as far as I can tell. Other text-based gamesāheck, other games of any sort that have an authored narrativeājust donāt have this level of freedom, where the world plays out haphazardly and chaotic events might completely tank the storyline. There have been only a handful of similar attempts, all of them ill-fated:
- Carnegie-Mellonās 1990s Oz Project produced only a small experiment called The Playground before being disbanded.
- FaƧade (2005) was another experiment, whose developers (not coincidentally) included a graduate of Carnegie-Mellon who had been involved with the Oz Project. A full-length follow-up called The Party was planned, but it never got off the ground.
- The Versu engine (2014) was a ācharacter AI for interactive storiesā that was abandoned before its release.
So, to put it more directly, I want to make a text-based game that is a detailed world simulation in which an authored story takes place (more on that below). I might borrow elements from other genres, such as real-time play like in MUDs, the gritty freedom of a survival sandbox RPG, and an alternative to parser-based input explored by Emily Short.
But the gameās essence is the setting: an open world that evolves over time, where pretty much anything can happen. Towns can be founded and wiped out by floods, animals can spread disease and be hunted to extinction, a drought can cause famine and malnutrition, the nobility can intermarry, discontented peasants can rise up in revolt.
What makes these world-simulating ambitions anything close to attainable in my (probably deluded) mind is what Iāve already said: there will be no graphics or other assets to worry about, just text. Also, certain things will be simpler because the world will be defined in physically low resolution, i.e. the world wonāt exist as a grid of small spaces like in Dwarf Fortress, but instead will be composed of various large areas or regions. (For example, a town could be one area, the region surrounding the town another area, and the mountains to the east yet another area.) This means I wonāt have to implement as much small-scale physics Ć la Dwarf Fortress. Even procedural generation will be limited, since itāll be easy enough to handcraft a world map as a setting for a story. The game can fill in the gaps like wildlife and minor locations, so that only the worldās overall shape and important details need to be defined by a storyās author.
Returning to the other half of the equation, how can an authored story happen in an open-world sandbox? Wouldnāt a story grind to a halt if one of its key people or places were destroyed? Well, yesā¦ remember, anything can happen! So stories will have to provide some minimum of contingency plans in case of mishap, so that the authored story has some level of interplay with the emergent narratives coming from the world simulation. Still, getting stuck through bad luck will always be a possibility. But maybe thatās OK. The unofficial motto of Dwarf Fortress, ālosing is funā, reminds us that chaotic failures are not always a bad thing.
Appendix A: writing text-based games in Ruby
If I were going to write traditional text-based games, there are many commonly-used authoring tools I could choose from. But I love Ruby, so I might have chosen one of these instead:
- Gamefic (GitHub) (active!) for parser-based interactive fiction. It can build games for the Web. Hereās an example storyās code and its explanation.
- TAGF ā Text Adventure Game Framework (active!) is a WIP project whose initial test case is to be able to reproduce Colossal Cave Adventure.
- ScottKit for ā80s-style text adventures. It has a nice DSL (see the tutorial).
- Tuvi is designed for kids but looks fun for adults too.
- Ruby Mud for building MUDs.
- AresMUSH (GitHub) (active!) is also for building MUDS. Compare to Evennia in Python.
Appendix B: Answering my inner critic
š¤Ø āA game? Seriously? Itās been ten years since youāve done any gaming. Now youāve just had your first baby. Isnāt it time to move on?ā
Itās true, I used to be a gamer but then in college, life got busy with other things, and itās been that way ever since. It was a good change, and I wish it had come sooner.
And yes, Iāve just welcomed my first baby into the world š¶ Heāll be his own person, of course, but Iāll encourage him to cultivate other interests besides gaming (like I wish Iād done sooner).
Still, making a game has been my dream since middle school. I never did get around to it, first because of my teenage lack of discipline, and then by my choice in college to study the humanities rather than software development. Now that Iāve ended up as a developer after all, why not go back to that dream?
Donāt get the wrong ideaāall this about āmy dreamā sounds more grandiose and ambitious than it is. The reason Iām contemplating a text-based game is precisely because Iāve just had a baby, and whatever project I start next has to be lightweight and easy to dip into while the baby is asleep on my lap and (tip for new parents!) my hands are free thanks to the incredibly useful Boppy pillow.
A text-based game sounds like the simple, restful project that I need right now.
š¼ āYou should really be making a Rails app, or a website, or some other useful thing. That would be best for your resume.ā
I already do Rails at my job, so a hobby Rails app would feel too much like work.
I really like Bridgetown (which I used to make this site), and Scarpe looks intriguing for desktop apps, but right now I donāt have a compelling reason to make another site, or a desktop app.
š¤ āHow about robotics? If youāre set on doing something frivolous, that would be way cooler.ā
True, I could get a Raspberry Pi plus this robot car kit. Its actions are written in Python, but I could write new actions in Ruby using the Artoo Ruby robotics framework, or (at a lower level) a Ruby port of the RPi.GPIO Python module. (Iām a big fan of Ruby, in case you havenāt noticed.)
These robot shenanigans could be fun, and they might be inspiring to my kid when heās a bit older. But right now Iāll pass, because itās not a baby-friendly project. My lack of robotics experience means it would be a big time investment, and the troubleshooting would be stressful. Plus, all the (literally) moving parts arenāt conducive to being immobilized with a baby sleeping in my lap.
š® āThen at least make a game thatās less lame than a text adventure! Youāve been wanting to try DragonRuby Game Toolkit, right?ā
Indeed I have, not least because DragonRuby has a great community around it.
The problem with me making a graphical game is sprites and other assets: making them (or even mixing-and-matching premade assets) would be tedious. I could make a game that uses geometrical shapes instead of sprites, maybe something along the lines of my childhood favorite Gravity Well, or the perennially fascinating sand games (e.g. Sandboxels, Powder Game), or simply a platformer that uses only rectangles (Thomas Was Alone is the best-known among many). But any of these may involve fairly complex geometry and physics, which are also high on my ādonāt want to deal with itā list.
In a text-based game, these headaches would be out of the picture (because there is no picture, heh). And later on if I choose to add graphical features and/or I want to distribute the game more widely, I can easily move it into DragonRuby. In the meantime Iāll simply output text to the terminal, just like it was done in the early days.