Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick fix to allow using nethack config files #15

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

mklissa
Copy link
Collaborator

@mklissa mklissa commented May 24, 2024

This is a quick fix to allow users to pass their Nethack options as a a configuration file (please see https://nethackwiki.com/wiki/Options) which has to be referred through options = ("@.nethackrc") where .nethackrc is the config file. The current code breaks as it only expects a tuple of options.

The difference with the current solution (say using this tuple of options https://github.com/heiner/nle/blob/main/nle/nethack/nethack.py#L53) is that a config file allows for greater customization of options, for example through specifications where not only OPTIONs is handled, but also AUTOPICKUP_EXCEPTION. here is an example below.

OPTIONs=autopickup
OPTIONs=boulder:0
OPTIONs=color
OPTIONs=disclose:+i +a +v +g +c +o
OPTIONs=nobones
OPTIONs=nocmdassist
OPTIONs=nolegacy
OPTIONs=nosparkle
OPTIONs=paranoid_confirmation:none
OPTIONs=pettype:none
OPTIONs=runmode:teleport
OPTIONs=showexp
OPTIONs=showscore
OPTIONs=time
AUTOPICKUP_EXCEPTION="<lizard corpse" 
AUTOPICKUP_EXCEPTION="<newt corpse"
AUTOPICKUP_EXCEPTION="<floating eye corpse"
MSGTYPE=hide "You see .*"
MSGTYPE=hide "You hear .*"

Most Nethack players use such configurations, for example this one.

@StephenOman
Copy link
Collaborator

Haven't gone into this much yet, but does line 2016 in files.c stop NLE from processing that NetHack config file?

@heiner
Copy link
Owner

heiner commented May 26, 2024

It probably does. We tried to limit the non-package state that influences nle at the time (people seem to find even time/date problematic...).

It's sad there's no env variable mechanism to change these settings :/. Ideally we'd control it well enough to not need parsing at each restart (RL environments are different from games in that they are restarted far, far more often, and the code here wasn't written in a way to be very efficient at restarts.)

@mklissa
Copy link
Collaborator Author

mklissa commented May 27, 2024

Oh yes, it does look like it's attempting to do so. However I have been using .nethackrc config files for the past few months without any trouble actually. I've used them on macOS and Linux, so maybe something else happens in the code at some other point? (I haven't modified anything else than what's in this PR)

I also totally agree that it would be great to have variables to provide proper control, but I imagine this would require a much deeper overhaul.

@StephenOman
Copy link
Collaborator

Maybe update the main README to have a citation guideline to include any .nethackrc settings so others can follow the work?

@@ -206,7 +206,13 @@ def __init__(

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

self.options = (
Copy link
Owner

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.

@StephenOman StephenOman added the enhancement New feature or request label Jun 22, 2024
Copy link
Collaborator Author

@mklissa mklissa left a comment

Choose a reason for hiding this comment

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

sounds good!

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