1 unstable release
Uses new Rust 2024
| 0.1.0 | Dec 27, 2025 |
|---|
#2480 in Algorithms
Used in rnssp
17KB
200 lines
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?