Improv, a javascript library for generative text

I’m currently working on a project involving some fairly demanding procedural generation of text. While that project isn’t ready to be announced yet, one of the first core pieces of functionality I wrote for it was a text-generating library. Said library had to be powerful, flexible, and fulfil the following needs:

  • Like Tracery, it needs to randomly choose text from nested webs of corpora, recursing itself.
  • Also like Tracery, it needs some basic templating functionality.
  • Unlike Tracery, it needs to run with the backing of a world model that can guide text generation.

Most of the ideas used to build this initial version of the tool were taken from Emily Short’s Annals of the Parrigues, which contains a long and extremely useful discussion of generative text in its epilogue.

Since this library is a separate module, I’ve decided to open source it. Improv has been released under the MIT license and can be viewed on Github. It’s an npm module, but it’s built so that it will work in a browser environment using a module-bundling tool like webpack or browserify. Improv is currently in active development, but the latest (0.4.2) version is one I consider to be reasonably usable.

Assuming you have node (v4 or newer), npm, and gulp installed, you can see a demo of Improv in action by doing:

$ git clone
$ cd improv
$ npm install
$ gulp demo
$ node demo_build/hms.js

This demo produces descriptions of fictional ships, along the lines of:

The HMS Reliable is a clipper commissioned 6 years ago.

Using a whale oil engine, she can reach speeds upwards of 32 knots. The Reliable is one of the new generation of vessels built to fight against the Arkodian fleet in the Short War. Her crew is known to be one of the more disciplined in the Navy. She is currently serving as a colonial troop transport.

The most obvious place to play around with Improv, at first, is Raconteur projects, since those are already friendly to including npm modules. NanoGenMo and ProcJam are some time away, but I look forward to seeing what people do with this tool in the meantime. Bug reports and pull requests are welcome.