galaxykate / tracery

Tracery: a story-grammar generation library for javascript
Apache License 2.0
2.11k stars 246 forks source link

Added support for setting random number generator, to make Tracery deterministic #19

Closed jhorneman closed 8 years ago

jhorneman commented 8 years ago

As briefly discussed on Twitter.

I've put Math.random in a variable, made Tracery use that instead of direct calls to Math.random, then added a function setRng to set that variable with a different function.

I've used this in the tests to be sure it worked, but you might not want that. Up to you: it's a tricky question.

I've documented the function in the readme file.