Skip to content

YAL-GameMaker/prng

Repository files navigation

PRNGs for GameMaker!

Quick links: blog post​ · documentation​ · itch​.io · source code
Supported versions: GM2022+, GM LTS
Supported platforms: all
See also: more GameMaker things!

This is a set of custom pseudorandom number generators for GameMaker!

You can use these to:

  • Have separate random number generators for different parts of the game.
  • Save/load generator's state (for example, to prevent "save scumming", or for networking)
  • Have more control over PRNG in general

See the "uses" section in the post for detailed examples!

Included generators

  • MINSTD
    This appears as minstd_rand in C++.
    Quick and simple.
  • A random_r style generator (called Rand0 for convenience)
    This is an LCG with mod=2³¹, mult=1103515245, inc=12345.
    Also quick and simple.
  • Xorshift (64-bit)
    The GML version of this generator is slower than above in VM builds, but much faster in YYC builds!
  • Well Equidistributed Long-period Linear (512-bit)
    This is a replica of what GameMaker itself uses for its random functions!
    The GML version is slightly slower than other generators.

Each generator has several variants to choose from:

  • GML: Constructor-based (r = gen.float(100))
  • GML: Array-based (r = minstd_float(gen, 100))
  • GML: Global (r = minstd_float(100))
  • C++ DLL edition (Windows-only)

See the "tests" section in the post for performance comparisons between different generators and their implementations! You might be surprised.

Building

See BUILD.md.

Meta

A tool by YellowAfterlife.
(partially) written in Haxe!

Custom license

About

Pseudorandom number generators!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published