A downloadable extension

Buy Now$6.95 USD or more

Quick links: blog post · documentation · 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.

Package contents

  • GML scripts (one per variant per generator, self-contained)
  • C++ DLL extension (optional)
    See notes on mixing it with scripts
  • Test project with benchmarks and unit tests.
  • Offline documentation
Published 15 hours ago
StatusReleased
CategoryAssets
AuthorYellowAfterlife
TagsGameMaker

Purchase

Buy Now$6.95 USD or more

In order to download this extension you must purchase it at or above the minimum price of $6.95 USD. You will get access to the following files:

PRNG-Scripts-for-GM2022+.zip 11 kB
Version 1.0.1a
PRNG-DLL-for-GM2022+.yymps 223 kB
Version 1.0.0
PRNG-GMBenchmark.yyz 563 kB
Version 1.0.1a
PRNG-docs.html 44 kB
Version 1.0.0