Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,21 @@ $ python -m nle.scripts.plot
steps
```


# Configuration file

NetHack allows for players to modify some details about the configuration of the
game (see options [here](https://nethackwiki.com/wiki/Options)). Some of these
configs may relate to the kind of messages being shown, the visual appearance
of the game or define macro-actions. Most NetHack players use such configurations,
see [this](https://www.hardfought.org/userdata/b/bouquet/nethack/bouquet.nhrc)
for example.

To leverage the full spectrum of possibilities offered by NetHack, the `options`
arugment in the NetHack [class definition](https://github.com/mklissa/nle/blob/main/nle/nethack/nethack.py#L165)
needs to receive the location the nethack config file, prefixed by `@`.
In the case where the config file is in the same directory as the launching script,
the `options` argument should receive a value of `@.nethackrc` where `.nethackrc`
is the name of the config file.

# Contributing

Expand Down
11 changes: 10 additions & 1 deletion nle/nethack/nethack.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,16 @@ def __init__(

if options is None:
options = NETHACKOPTIONS
self.options = list(options) + ["name:" + playername]

# Check if the user has passed a configuration file to define the options.
# This is done by specifying the options variable as "@.nethackrc",
# where .nethackrc is the file containing the configs.
self.options = (
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit:

self.options = list(options)
if options[0][0] != "@":
    self.options.append(f"name:{playername}")

and perhaps also a comment what this does.

And perhaps a test to show this works? I'm still a bit unclear if this is a good idea as it pulls in yet another external source of state.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added a comment to the file as well to the README file.

I think having the config file could potentially help manage NetHack experiments, where a configuration file would be associated with a certain experiment.

Since the config file also allows changing the visual aspect of NetHack it could also allow for testing transfer and generalization across that modality.

But yeah, it would be a advanced feature of the NLE, most people would probably not touch this.

list(options) + ["name:" + playername]
if options[0][0] != "@"
else list(options)
)

if playername.split("-", 1)[1:] == ["@"]:
# Random role. Unless otherwise specified, randomize
# race/gender/alignment too.
Expand Down