diff --git a/README.md b/README.md index 0f67f5ea6..90c67c71b 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/nle/nethack/nethack.py b/nle/nethack/nethack.py index d0e2091ed..576f0b9ab 100644 --- a/nle/nethack/nethack.py +++ b/nle/nethack/nethack.py @@ -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 = ( + 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.