Random Seedable

2020

An open-source collection of random number generators which has been used by Microsoft and the generative art community.
Cover Image

Cover Image

1 / 1

Random-seedable is an open-source collection of random number generators written in JavaScript with built-in support for Typescript. I built it up over a number of weeks while trying to gather a greater understanding of modern seedable random number generators. Its current audience is developers writing games, generative artists, and is now used as part of Microsofts' FluentUI.

What I Did

- Implemented both 32 and 64 bit versions of many popular and frequently used random number generators (LCG, PCG, XorShift etc.) in both C++ and JavaScript. It is one of the few JS libraries which contain 'true' 64-bit generators as each uses the newly introduced BigInt class to perform its generation functions.

- Full API covering the most common functions expected of a random number generator(shuffle, randRange, choice, coin.)

- Full suite of tests based on reference data from C++ versions which are themselves based on original code, ensuring that all implementations are correct.

Results

As is often the case in programming you start off writing one function and before you know it you've written a well-tested library waiting for a readme and the npm publish command. I originally wrote this while trying to better understand random number generators, perlin noise, and other such algorithms. So I was very pleasantly surprised to discover that Microsoft had started using it as part of one of their flagship open-source projects, as well as numerous generative artists and game developers. It's a fantastic feeling writing something so niche and finding that so many people needed it.