| Crates.io | gamemaker-rand |
| lib.rs | gamemaker-rand |
| version | 0.1.0 |
| created_at | 2025-12-27 05:58:13.182084+00 |
| updated_at | 2025-12-27 05:58:13.182084+00 |
| description | Rust implementation of the WELL512a PRNG used by Gamemaker, and related things |
| homepage | |
| repository | https://github.com/babit56/rns-seed-predictor |
| max_upload_size | |
| id | 2006743 |
| size | 16,220 |
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!
// 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();
cargo build -p gamemaker-rand