Using Improv

Improv (source code, documentation) is a powerful procedural generation engine by Bruno Dias.

While the questions of why you might need Improv and how to use it are sorta out of the scope for this document, there is an important details on how to use it with Salet.

You see, since November 2016 Improv allows to use a custom RNG (random number generator). If you hook it up with Salet's RNG (conveniently exposed as salet.rnd) it will return the same text every time the player loads the game. If you don't, however, it will return different text every time.

Long story short, here's minimal code:

Improv = new ImprovEngine(data, {
  rng: () ->
    return salet.rnd.randf()

and a real example:

ImprovEngine = require('improv')
Improv = {}

$.holdReady( true )
$.getJSON('game/procgen/'+i18n.lang+'.json', (data) ->
  Improv = new ImprovEngine(data, {
    rng: () ->
      return salet.rnd.randf()
    filters: [
    reincorporate: false

  $.holdReady( false )


  • babel-polyfill is needed for browser compatibility; Improv is written in ES6, it doesn't work in older browsers as it is
  • holdReady bit loads procgen data with an AJAX request and forbids the game to start until the request is finished.

and the rest is explained in Improv documentation.