Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Add nle_settings to nledl interface, don't use environment variables #291

Merged
merged 5 commits into from
Dec 16, 2021

Conversation

heiner
Copy link
Contributor

@heiner heiner commented Nov 30, 2021

This also gets rid of the need to write a file for WIZKIT.

Fixes the race condition in #287

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 30, 2021
And while we are at it, let's not actually write to disk for this
one either.

This allows us to remove _set_env_vars() from nethack.py.
@heiner heiner force-pushed the heiner/nledl-interface branch from c9b7e63 to dab0d23 Compare November 30, 2021 15:44
Copy link
Contributor

@samvelyan samvelyan left a comment

Choose a reason for hiding this comment

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

Nice feature! Looks neat.

Copy link
Contributor

@cdmatters cdmatters left a comment

Choose a reason for hiding this comment

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

generally lgtm and a good change; just one question on off by ones, and one comment on putting many options in one spot (ie TERM to the options struct, and simplifying get env function - so if future we only set options in one location.)

*/
char hackdir[4096];
char options[32768];
char wizkit[4096];
Copy link
Contributor

Choose a reason for hiding this comment

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

don't need TERM?

Copy link
Contributor

Choose a reason for hiding this comment

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

just saw that below we always set to "ansi" in get env. is it worth including it here instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We kind of require "ansi" as the value ever since dropping the dependency on ncurses, so any other user-supplied value would break it I think.

: dlpath_(std::move(dlpath)), obs_{}, spawn_monsters_(spawn_monsters)
{
if (hackdir.size() > sizeof(settings_.hackdir) - 1) {
throw std::length_error("hackdir too long");
}
if (nethackoptions.size() > sizeof(settings_.options)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

is one of these off by one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. The reason for the difference is that in nle.c we need to add a / at the end. This is perhaps a bit unclean, but reflects what NetHack itself does in a comparable situation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But that / only needs to be added to HACKDIR.

void
set_wizkit(std::string wizkit)
{
if (wizkit.size() > sizeof(settings_.wizkit)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

same viz sizes

@heiner heiner merged commit 758eff9 into main Dec 16, 2021
@heiner heiner deleted the heiner/nledl-interface branch December 16, 2021 15:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants