Tenliner Cave Adventure in R: Miniature Text Adventure Ported From the ZX81
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Computing has come a long way in the past 75 years. I learned how to write code in the 1980s on my tiny 1 kilobyte ZX81 home computer. With only 1 kilobyte of memory, capabilities were limited, but this machine set me off on an adventure writing code in the BASIC language. An active subculture of computer enthusiasts still develops new code and keeps these old machines alive. I recently stumbled across the fantastic Tenliner Cave Adventure (2016) by Einar Saukas from Brazil. This tiny ZX81 program provides a fully functional classical text adventure using some cunning techniques. This article contains a port of this game to the R language to explore its inner workings.
Interactive Fiction
Text adventures, or interactive fiction, were trendy in the 1980s. The basic premise is that the computer shows a text and the player responds with a text command. The computer parses the command, calculates the new state of play and progresses the game with a new bit of prose. Last year I wrote an article about writing interactive fiction using the R language with a translation of Secret of Landusia. The Tenliner Cave Adventure provides a minimalist approach by squashing the basic principles of a text adventure into 1024 bytes of memory. The backstory of this Saukas' mini-adventure is a typical fantasy setting:
As a young warrior apprentice, you have been chosen by the village elders to seek out the evil menace that lurks in some nearby caves. Once found, use any means at your disposal to defeat it… Good luck on your quest!

Tenliner Cave Adventure in R
The Tenliner Cave Adventure is a jewel of efficient programming. The game is simple, but it has all typical elements of a text adventure. As I no longer own a ZX81, I could not resist translating this code to R to be able to play and reverse-engineer the game.
The game recognises the following commands:
-
north, south, east, west (move)
-
inventory
-
look
-
look