Ruby - the ultimate adventure game language?
I’ve always had a weakness for adventure games – especially those of the ‘classic’ (text-based) variety. This may be explained by the fact that the first time I realized that computers could do magic was when a friend introduced me to Zork in the early ‘80s.
Up until that moment I had only used my PC for doing boring things such as word processing and calculating totals in spreadsheets. In fact, I had bought my PC specifically as a replacement for my old typewriter. I was, in those days, a pop music journalist and I spent my time interviewing the likes of George Michael, Judas Priest, Simon Le Bon and Boy George. I had no interest in computers and it had certainly never crossed my mind to learn how to program.
The breakthrough came when I first saw someone doing word processing on an old Apple II machine. I remember the moment well. I had just been to interview cross-dressing film star and disco diva, Divine (whose role in the film, Hairspray has now been revived, somewhat improbably, by John Travolta). Back in the office of Divine’s agent, I saw that press releases were being written on the aforementioned Apple II. What surprised me more than anything was that when an error was made, Divine’s agent just backspaced to delete it and carried on writing. When I made errors on my typewriter, I had to either blank them out with correction fluid or – in the worst cases – throw the sheet of paper away and start all over again from the beginning.
Less than two weeks after that I was the proud owner of my first PC – an Olivetti M-24 with a monochrome (green-on-black) screen, a massive 512K of memory and a single floppy disk drive (a hard disk was beyond my budget).
For a while I just used it as a ‘clever’ typewriter. But when first I played Zork, my opinion of that PC changed dramatically. I was astounded to discover that whole worlds could live inside a computer, that you would walk from place to place, interact with trolls and thieves, open doors, take treasures and generally cause untold mayhem inside a virtual world of words.
To this day, text adventures are still more magical to me than games with the latest gee-whiz graphics; just as novels are more magical to me than films. I enjoy them both but, in a contest, words would win over pictures every time...
Having played somebody else’s adventure game, I immediately wanted to create one of my own. And that, I soon discovered, meant learning how to program. I bought a copy of Borland’s (for the day) remarkable Turbo Pascal compiler and set to work. Every spare moment I had for the next year was spent writing a game called The Golden Wombat Of Destiny. Amazingly, to this very day, there are people who are still playing it. Some of them write to me. Often they tell me how they grew up playing The Golden Wombat with their parents and now they play it with their children or grandchildren. Heck, that makes me feel old! If anyone reading this is playing it with their great-grandchildren, please don’t write and tell me. I know you mean well but it would only depress me.... :-(
Great as it was, Turbo Pascal was not the ideal language for an adventure game. Back in those days, it didn’t even have objects – and objects are so useful for an adventure.
In the years since I first began to program, I moved out of pop music journalism and into the world of professional programming and writing – first as a journalist, columnist and magazine editor; and now as the Technology Director for SapphireSteel Software. It’s been an interesting journey. Over the years, I’ve programmed in Java, C++, C#, Prolog, Delphi, Smalltalk and a few other languages besides. My love of adventuring has never left me, though, and I have written small games in Prolog, Java, C# and Smalltalk. But, of all the languages I’ve thus far used, I have to say that Ruby strikes me as the one that is most attractive for adventure game writing.
A lot of my time these days is spent on ‘serious programming’ (much of it in C#) – most of it related to the development of Ruby In Steel. But I need a break from that every once in a while. Which is why I’ve decided to write a series of adventure game programming with Ruby. The first part is over on the Bitwise site now. If you love text adventures as much as I do, or if you just want to try your hand at some ‘just for fun’ Ruby coding, why not give it a try...
|Read Adventures In Ruby (Bitwise Magazine site)|
I just started learning Ruby and the first thing I thought was, "wow, this would be great for a text game!" As student in Game & Simulation design we have only ever worked with C++ and although it generally supports the big dogs, the games I grew up playing were all text. I have more fond memories as an avid gamer playing text games than I ever have with any of the current titles. The people who were able to design these text games were great and often always playing themselves! I’ve certainly never spoken to any big name developers or even their underlings but meeting someone just as creative over telnet was really what got me interested in coding.
I love both Ruby and "Interactive Fiction" (as they call it now), so I applaud you. BTW, this is such a peculiar domain that the "ultimate language" for it is arguably an dedicated external DSL.
An IF program is mostly natural-language text. Ruby is good at mixing text into regular code, but a dedicated parser still has the edge. Also, the libraries that you need for IF are way more complex than one might think initially, so a would-be author would be better off not reinventing this very complicated wheel.
In particular, there are two very good languages for this domain: TADS 3 and Inform 7. Inform 7 is particularly fascinating, because it’s one of the very few programming languages that manages to look like natural language and still work. For example, this is an Inform program:
Yes, it actually compiles. :)
TADS looks more traditional. In my upcoming book on Ruby metaprogramming, I use a snippet of TADS as a first example of a DSL.
Of course, this doesn’t mean that we cannot have some good fun coding IF in Ruby, so your article is very welcome. ;)