Open
Conversation
added 4 commits
September 2, 2021 10:06
[NEP19](https://numpy.org/neps/nep-0019-rng-policy.html) states: "The preferred best practice for getting reproducible pseudorandom numbers is to instantiate a generator object with a seed and pass it around." Therefore, this has been update to allow for reproducible results in all modules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NEP 19 — Random number generator policy states that regarding
numpy.random.*"[the] preferred best practice for getting reproducible pseudorandom numbers is to instantiate a generator object with a seed and pass it around". According to this, the currently used globalRandomStatein numpy can cause problems. Therefore, this pull request proposes replaces it using the numpy random number generators instead.With this pull request, a random number generator (
rng) object can be passed to thecore(with a newdefault_rnggenerator object as the default argument). It also adds the same argument to thesamplefunction incubicasa.py, to theRandomSpawnsclass and therandom_empty_positionsfunction inmodules.py, theRandomChainfunction infsm.py, and theinit_textures,wall_pattern,random_lights,sceneryfunctions inscene.py.In the
RandomSpawnsclass (modules.py), the corerngis automatically passed to therandom_empty_positionsduring initialization. Likewise, therngobject is passed fromscenerytorandom_lightsandinit_textures, and frominit_texturestowall_pattern.This way, during environment setup, one can create a single (potentially seeded)
rnggenerator object to pass to all subsequent use cases.