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

Env updates #87

Merged
merged 4 commits into from
Oct 1, 2020
Merged
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
18 changes: 11 additions & 7 deletions nle/env/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,7 @@
ASCII_n = ord("n")
ASCII_ESC = nethack.C("[")

FULL_ACTIONS = list(nethack.ACTIONS)
# Removing some problematic actions
FULL_ACTIONS.remove(nethack.Command.SAVE)
# TODO: consider re-adding help eventually, when we can handle its state machine
# and output.
FULL_ACTIONS.remove(nethack.Command.HELP)
FULL_ACTIONS = tuple(FULL_ACTIONS)
FULL_ACTIONS = nethack.USEFUL_ACTIONS

BLSTATS_SCORE_INDEX = 9

Expand Down Expand Up @@ -241,6 +235,16 @@ def __init__(
high=np.iinfo(np.uint8).max,
**nethack.OBSERVATION_DESC["message"],
),
"program_state": gym.spaces.Box(
low=np.iinfo(np.int32).min,
high=np.iinfo(np.int32).max,
**nethack.OBSERVATION_DESC["program_state"],
),
"internal": gym.spaces.Box(
low=np.iinfo(np.int32).min,
high=np.iinfo(np.int32).max,
**nethack.OBSERVATION_DESC["internal"],
),
"inv_glyphs": gym.spaces.Box(
low=0, high=nethack.MAX_GLYPH, **nethack.OBSERVATION_DESC["inv_glyphs"]
),
Expand Down
38 changes: 35 additions & 3 deletions nle/nethack/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class Command(enum.IntEnum):
DROP = ord("d") # drop an item
DROPTYPE = ord("D") # drop specific item types
EAT = ord("e") # eat something
ESC = C("[") # escape from the current query/action
ENGRAVE = ord("E") # engrave writing on the floor
ENHANCE = M("e") # advance or check weapon and spell skills
FIRE = ord("f") # fire ammunition from quiver
Expand All @@ -111,8 +112,8 @@ class Command(enum.IntEnum):
LOOK = ord(":") # look at what is here
LOOT = M("l") # loot a box on the floor
MONSTER = M("m") # use monster's special ability
MOVE = ord("m") # move, no pickup
MOVEFAR = ord("M") # move far, no pickup
MOVE = ord("m") # Prefix: move without picking up objects/fighting
MOVEFAR = ord("M") # Prefix: run without picking up objects/fighting
OFFER = M("o") # offer a sacrifice to the gods
OPEN = ord("o") # open a door
OPTIONS = ord("O") # show option settings, possibly change them
Expand All @@ -130,7 +131,7 @@ class Command(enum.IntEnum):
REMOVE = ord("R") # remove an accessory (ring, amulet, etc)
RIDE = M("R") # mount or dismount a saddled steed
RUB = M("r") # rub a lamp or a stone
RUSH = ord("g") # rush to a chosen direction
RUSH = ord("g") # Prefix: rush until something interesting is seen
SAVE = ord("S") # save the game and exit
SEARCH = ord("s") # search for traps and secret doors
SEEALL = ord("*") # show all equipment in use
Expand Down Expand Up @@ -164,6 +165,37 @@ class Command(enum.IntEnum):
+ list(Command)
)

NON_RL_ACTIONS = (
Command.ANNOTATE, # Could potentially be useful.
Command.AUTOPICKUP,
Command.CONDUCT, # Could potentially be useful.
Command.EXTCMD, # Potentially useful for some wizard actions.
Command.EXTLIST,
Command.GLANCE,
Command.HELP,
Command.HISTORY,
Command.KNOWN, # Could potentially be useful.
Command.KNOWNCLASS, # Could potentially be useful.
Command.OPTIONS,
Command.OVERVIEW, # Could potentially be useful.
Command.PREVMSG, # Could potentially be useful.
Command.QUIT,
Command.REDRAW,
Command.SAVE,
Command.SEEALL, # Could potentially be useful.
Command.TRAVEL, # Could potentially be useful.
Command.VERSION,
Command.VERSIONSHORT,
Command.WHATDOES,
Command.WHATIS,
)

_USEFUL_ACTIONS = list(ACTIONS)
for action in NON_RL_ACTIONS:
_USEFUL_ACTIONS.remove(action)
USEFUL_ACTIONS = tuple(_USEFUL_ACTIONS)
del _USEFUL_ACTIONS

_ACTIONS_DICT = {}
for enum_class in [
CompassDirection,
Expand Down