Wednesday, May 6, 2009

Towards procedurally generated content in Inform 7

Recently, there was a bit of newsgroup discussion about procedurally generated content, and how this has been a relatively unexplored field in IF. Which is curious, because text, at least in certain forms, is a lot easier to procedurally generate than most other media.

The discussion was a happy coincidence, because this is something I've been interested in and playing around with for a while. In the process of this playing I've created a pair of low-level extensions, which you can preview at the links below and should be appearing on the Inform 7 Extensions Page before long.

Procedural Randomness lets you create predictably random sequences of text, so that for instance you could have the walls of a room be random but consistent colors:

set seed to location;

say "The walls are [one of]green[or]white[or]red[or]fuchsia[or]maroon[with procedural randomness].";


Every time you returned to the same location, the walls would be the same color.

The second extension, Dynamic Rooms, makes it easy to create and destroy rooms during play. (It's so easy because the extension's just moving around a stock of unused rooms, rather than fiddling with creating objects in memory, like the more advanced Dynamic Objects by Jesse McGrew.)


Understand "dig [a direction]" as excavating. Carry out excavating: let rm be a newly created room noun of location with name "Cave".


Neither of these are terribly exciting in and of themselves, but will serve as the bedrock underneath more elaborate extensions to come (which in turn were spin-offs of the really interesting problems I'm working on). I'm also curious to see what other uses other people put them to; I'd also love to hear from anyone with ideas, suggestions, or similar work along these lines.