Random number generator. Native, multi algorithm and instance based

Based on the idea behind Defold-random, i created a new extension for native, instance based (non-global) random number generators.

Hereby i present defold-rng

This extension has 3 main aspects:

  • Native, to be as fast as possible
  • Instance-based (no global state), so true procedural generation is possible
  • Multi-algorithm, so we can add multiple algorithms and choose the best for each use and need

To start with, we have PCG32 algorithm. Others will follow.

I just started in Game Development, and after checking reviews for more than 30 engines and given my own expectations and values, i decided to stick with Defold.

Procedural generation is something i would like to invest in. I felt the need for this extension, so i created it, based on other great extensions, such as defold-random.

Despite having 30 year experience as a programmer, i just recently started with Lua, and C/C++ is something i don’t have contact with for more than 25 years.

As a seasoned programmer, i feel code reuse is a must, and extensions are the best way to have it in Defold.

Hopefully this is the first (of many) extension contributions for the Defold community.

20 Likes

Cool. Thank you for sharing!

4 Likes

Just published version 1.1.0, adding support for TinyMT32 (Tiny Mersenne Twister).
This one is similar to the original Mersenne Twister (MT19937), but uses way less state buffer (only 7 uint32, instead of 2.5kb)

5 Likes