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

Commit

Permalink
Add "score" to internal observation.
Browse files Browse the repository at this point in the history
What exactly NH means by score is a bit context-dependent. The value
u.urexp factors into botl_score() in botl.c (if enabled) as well as
into the computation in really_done() in end.c. In many cases, the
result of botl_score() will be what really_done() reports as the
end-of-game score. In many other cases, it won't: E.g. after dying
(not quitting, escaping, ascending or bug-related exits), score for
acquired gold is reduced by 10%. Also if escaped or ascended, valuable
gems, artefacts etc will give extra score. The computation in end.c
adds to u.urexp, which will reflect the end-of-game score for a few
briefs "steps" at the very end of the game (but not before).
  • Loading branch information
Heinrich Kuttler committed Jun 4, 2021
1 parent 8f13c34 commit c5f077c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/nleobs.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#define NLE_MESSAGE_SIZE 256
#define NLE_BLSTATS_SIZE 25
#define NLE_PROGRAM_STATE_SIZE 6
#define NLE_INTERNAL_SIZE 8
#define NLE_INTERNAL_SIZE 9
#define NLE_INVENTORY_SIZE 55
#define NLE_INVENTORY_STR_LENGTH 80
#define NLE_SCREEN_DESCRIPTION_LENGTH 80
Expand Down
4 changes: 4 additions & 0 deletions nle/tests/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
#
# Copyright (c) Facebook, Inc. and its affiliates.

# Requires
# pip install pytest-benchmark
# to run

import pytest

import numpy as np
Expand Down
5 changes: 4 additions & 1 deletion win/rl/winrl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ NetHackRL::fill_obs(nle_obs *obs)
obs->internal[5] = nle_seeds[0]; /* core */
obs->internal[6] = nle_seeds[1]; /* disp */
obs->internal[7] = u.uhunger;
obs->internal[8] =
u.urexp; /* score (careful! check botl_score() and end.c) */
}

if ((!program_state.something_worth_saving && !program_state.in_moveloop)
Expand Down Expand Up @@ -412,7 +414,8 @@ NetHackRL::fill_obs(nle_obs *obs)
}
}
if (obs->screen_descriptions) {
memcpy(obs->screen_descriptions, &screen_descriptions_, screen_descriptions_.size());
memcpy(obs->screen_descriptions, &screen_descriptions_,
screen_descriptions_.size());
}
}

Expand Down

0 comments on commit c5f077c

Please sign in to comment.