Observations¶
Choose an observation mode with the observation argument to make_env():
from mudgym import make_env
env = make_env(observation="parsed")
observation, info = env.reset()
env.close()
Every observation includes text and points, including custom field selections. The base environment tracks points from the initial quickscore and subsequent game events, and uses that same score to calculate rewards.
text¶
Contains the common text and points observations only.
from mudgym import make_env
env = make_env(observation="text")
observation, info = env.reset()
env.close()
print(observation["text"])
Beaten track.
You're on a rough east-west track with a dense forest to the north and pasture to the south. It is raining.
parsed¶
Adds keyed data parsed from game output.
| Key | Value |
|---|---|
points |
200 |
room_name |
beaten track near cliff |
room_name_index |
38 |
here |
cliff, road |
features |
cliff, road |
mobiles |
empty |
players |
empty |
vitals |
[59, 59, 54, 54, 67, 67, 0, 59] |
flags |
[0, 0, 0, 0] |
reset_minutes |
105 |
weather |
fair |
weather_index |
1 |
available_exits |
[1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1] |
available_exit_names |
north, east, south, northeast, southeast, southwest, out, swampward |
portables |
empty |
inventory |
empty |
available_exit_names lists the directions available according to the exits command.
vitals is [stamina, max_stamina, effective_strength, strength, effective_dexterity, dexterity, magic, max_magic], and flags is [blind, deaf, crippled, dumb].
cheats¶
Adds hidden state output from the mgcheats command, some of which wouldn't typically be known to a player. Most notably room_id.
| Key | Value |
|---|---|
points |
200 |
vitals |
[60, 60, 56, 56, 64, 64, 0, 60] |
flags |
[0, 0, 0, 0] |
reset_minutes |
105 |
weather |
fair |
weather_index |
1 |
available_exits |
[1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1] |
available_exit_names |
north, east, south, west, northeast, southeast, southwest, northwest, out, swampward |
room_id |
mtrack2 |
room_id_index |
688 |
room_name |
beaten track |
room_name_index |
37 |
fighting |
0 |
dark |
0 |
glowing |
0 |
asleep |
0 |
gifted |
0 |
here |
road |
players |
empty |
mobiles |
empty |
portables |
empty |
inventory |
empty |
bytes¶
Adds raw_bytes, a uint8 NumPy array padded or truncated to 16,384 bytes. The full, unpadded bytes are available as info["raw_bytes"].
Use RawBytesField(max_bytes=N) to change the array size.
Shown as a bytes literal here for readability:
b"\x1b[32mBadly-paved road\x1b[37m.\n\x1b[0;32;40mYou are standing on a badly-paved road, which runs from the east to stop at a large wall constructed to the west. There is a narrow gap in this blockage, but it is so tight that if you wanted to go that way you'd have to drop everything to get through. North and south are the footh"
...
Creating your own keys¶
Custom observations are defined by selecting fields and the keys each field contributes:
from mudgym import make_env
from mudgym.envs.fields import FEScoreField, SuperQuickLookField
env = make_env(
field_parsers=(
SuperQuickLookField(include_keys=("room_name", "here")),
FEScoreField(include_keys=("vitals",)),
)
)
env.close()
You can add your own field parsers in the same way by creating an ObservationField subclass. Take a look at the fields in mudgym/envs/fields/ to use as a reference.