gamemaker-rand

Crates.iogamemaker-rand
lib.rsgamemaker-rand
version0.1.0
created_at2025-12-27 05:58:13.182084+00
updated_at2025-12-27 05:58:13.182084+00
descriptionRust implementation of the WELL512a PRNG used by Gamemaker, and related things
homepage
repositoryhttps://github.com/babit56/rns-seed-predictor
max_upload_size
id2006743
size16,220
Babit (babit56)

documentation

README

Gamemaker RNG

Gamemaker RNG functions, implemented in Rust. Functions accept and return Reals, which are integers or floats.

Currently the main implementation is a WELL512a based on Lomont 2008 and reverse engineering of an empty YYC binary on Windows. I have not thoroughly checked that the same impl is used for all or any other platforms, but preliminary testing indicates at least the Windows VM and Linux VM runtimes use it. I also think HTML uses it, but the implementation details are subtly different, so I can't say for sure without testing. JS shenanigans also don't help! The WELL512a is implemented wrong (specifically set_seed()), so for educational purposes a "correct" impl is also included (see WELL512a::with_correct_tlcg()). Other than that I am not familiar with any standard RNG's in the Gamemaker community, but I'm open to adding them if wanted. Issues or a pull requests are welcome!

Usage

// Bring RNG functions into scope
use gamemaker_rand::GMRand;

// Instantiate the default RNG (currently Windows based)
let rand = gamemaker_rand::rng();

// Functions accept and return Real's, which requries quite a few .into()'s
rand.set_seed(1729.into());
let dice_roll: usize = rand.irandom(6.into()).into();

Building

cargo build -p gamemaker-rand

TODO

  • WELL512a implementation
  • Tests against Windows/Linux
  • Tests against HTML, maybe others
  • Finish docs
  • More examples?
Commit count: 0

cargo fmt