Skip to content

Conversation

@StephenOman
Copy link
Collaborator

This feature adds the capability to pass an extra parameter lgen to the NLE seed() function for the purposes of having a deterministic dungeon layout, while allowing the in-game play to be randomly guided (e.g. combat etc.)

It works by creating a new Random Number Generator using this seed value when the environment reset() function is called. This RNG is swapped with the NetHack core RNG during the level generation (see maklev.c:1003), where random numbers are sampled from the known RNG. It is then swapped back once the level is created (see maklev.c:1041), and subsequent random numbers will be sampled from core.

The RNGs are swapped again each time a new level is generated as the hero descends through the dungeon, ensuring that level generation random number sampling is kept separate from the in-game random number samples.

@StephenOman StephenOman added the enhancement New feature or request label Mar 19, 2025
Copy link
Collaborator

@heiner heiner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

chars: A row x columns numpy array of chars.
colors: A numpy array of colors (0-15), same shape as chars.
cursor: An optional (row, column) index for the cursor,
chars: A row x columns numpy array of chars.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was an attempt to follow the Google Python style guide https://google.github.io/styleguide/pyguide.html#383-functions-and-methods

(no harm in changing the style here, but this is why it looked like that before).

try {
lgen = pyLgen.cast<unsigned long>();
} catch (py::cast_error) {
/* Is 0 a valid seed number? Does nothing even matter?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😂

@StephenOman StephenOman merged commit eae89fc into main Apr 9, 2025
24 checks passed
@StephenOman StephenOman deleted the seed-level-generation branch April 9, 2025 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants