Skip to content

add a way to store and set the state of the random number generator seed #3073

@attic-stuff

Description

@attic-stuff

Is your feature request related to a problem?

yes! currently if you pull this slick move:

/*fun event*/
randomise();
savedseed = random_get_seed();
irandom(5);
irandom(5);

you will get two random numbers. if you serialize that seed, and then do this when the game launches again:

/*fun event*/
random_set_seed(savedseed);
irandom(5);
irandom(5);

you will get the same two random numbers as when we first generated this seed! it would be nice to be able to save the state of the random number generator so that you can sort of pick up where you left off when it comes to random calls.

Describe the solution you'd like

i would like to see two (2) functions added to gamemaker for this: a random_get_state() and a random_set_state(); the former would return the state of the rng given the current seed and the latter would be able to "catch up" the state of the current seed to whatever random_get_state() returns.

Describe alternatives you've considered

friends i have had to make my own wrapper for every random call to log the type of call, then run through every call at game relaunch to catch the state up.

Additional context

there is no additional context, that's the end folks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestNew feature (or a request for one)

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions