Skip to content

Instantly share code, notes, and snippets.

@dariusk
Created December 16, 2013 14:41
Show Gist options
  • Save dariusk/7987989 to your computer and use it in GitHub Desktop.
Save dariusk/7987989 to your computer and use it in GitHub Desktop.

I'm collecting practical use cases for random.seed() functions. Here's an example of what I'm talking about, in pseudocode:

random.seed(12345);
random() // 0.221038...
random() // 0.858932...

// Switch seeds, get different results
random.seed(6789);
random() // 0.633732...
random() // 0.939101...

// Use original seed, get original results
random.seed(12345);
random() // 0.221038...
random() // 0.858932...

Please comment below with use cases for this function. I've started off with my own use case.

@dariusk
Copy link
Author

dariusk commented Dec 16, 2013

This can be very useful for unit/integration tests of systems that use pseudorandom functions. For example, if I'm building a combat system in a game, I'd like to make sure that the dice roll the same way every time I run tests against the combat system. This way I can verify the expected outcome of combat every time.

@dariusk
Copy link
Author

dariusk commented Dec 16, 2013

For "skill gaming" applications where money is involved, U.S. legislation requires that tournaments provide the same pseudorandom seeds to every participant in the tournament. For example, if we're competing to see who does the best in a solitaire card game, we need to make sure the shuffle comes out the same every time for every player.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment