Skip to content

Unified Random Number Generator#1

Open
JulianKu wants to merge 4 commits intoandyljones:masterfrom
JulianKu:feature/add-unified-rng
Open

Unified Random Number Generator#1
JulianKu wants to merge 4 commits intoandyljones:masterfrom
JulianKu:feature/add-unified-rng

Conversation

@JulianKu
Copy link
Copy Markdown

@JulianKu JulianKu commented Feb 9, 2022

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 global RandomState in 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 the core (with a new default_rng generator object as the default argument). It also adds the same argument to the sample function in cubicasa.py, to the RandomSpawns class and the random_empty_positions function in modules.py, the RandomChain function in fsm.py, and the init_textures, wall_pattern, random_lights, scenery functions in scene.py.

In the RandomSpawns class (modules.py), the core rng is automatically passed to the random_empty_positions during initialization. Likewise, the rng object is passed from scenery to random_lights and init_textures, and from init_textures to wall_pattern.

This way, during environment setup, one can create a single (potentially seeded) rng generator object to pass to all subsequent use cases.

Julian Kunze 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant