SFMT and PCG Random Number Generator Extensions

Hey everyone, I’ve made two new extensions for random number generation.

They both are quite sophisticated and suitable for many advanced applications. Regular application is also fine because they provide quite fast, reliable generation and a set of quality of life functions such as d4()…d20() for simulating dice rolls or shuffle() for table shuffling.

PCG Extension is particularly based on the C++ version of PCG, which has the most features. Some of the notable features are being able to generate sequences that don’t repeat for a very long period or using an array of values as a seed, providing even more possible initial states (SFMT also has it).

Moreover they both can generate 64-bit random numbers in case you need it. In Lua it’s hard to work with such values but Defold supports 64-bit buffers and I can simply return an 8 byte long binary string.

Please be sure to read their official documentation to make sense of their features.

SFMT Random-thumb
SFMT Random - GitHub - Lerg/extension-sfmtrandom: SFMT Random Extension for Defold

PCG Random-thumb
PCG Random - GitHub - Lerg/extension-pcgrandom: PCG Random Extension for Defold

Both provide test projects you can run or inspect. As well as API definitions for autocompletion in the Defold editor.

Tested them on all platforms (except linux, but should be fine) and they produced the same output given the same seed.

Also if you like them please consider supporting me on Patreon, that support is crucial for me at the moment - Lerg | creating Games, YouTube videos and gamedev assets | Patreon

Please tell me if you find any bugs or if you believe something is implemented not quite right.

17 Likes