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 near cliff.
You are at the end of a rough track. There is a dangerous cliff to the west marked "Lovers' Leap". It is raining.
parsed¶
Adds keyed data parsed from game output.
| Key | Value |
|---|---|
points |
200 |
room_name |
dally lane |
room_name_index |
118 |
here |
streetsign, Logan the protector, road |
features |
road |
mobiles |
empty |
players |
empty |
vitals |
[61, 61, 62, 62, 57, 57, 0, 61] |
flags |
[0, 0, 0, 0] |
reset_minutes |
105 |
weather |
fair |
weather_index |
1 |
available_exits |
[1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1] |
available_exit_names |
north, south, west, southwest, northwest, up, out, swampward |
portables |
streetsign |
inventory |
empty |
available_exit_names is the available subset of DIRECTIONS, in the same game-native order as the set bits in available_exits.
over and swampward are MudGym's public names for the game's internal jump and swamp directions.
vitals is [stamina, max_stamina, effective_strength, strength, effective_dexterity, dexterity, magic, max_magic]; 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 |
[75, 75, 44, 44, 61, 61, 0, 75] |
flags |
[0, 0, 0, 0] |
reset_minutes |
105 |
weather |
raining |
weather_index |
4 |
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 |
mostart |
room_id_index |
544 |
room_name |
road opposite cottage |
room_name_index |
427 |
fighting |
0 |
dark |
0 |
glowing |
0 |
asleep |
0 |
gifted |
0 |
here |
rain, road |
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[32mDally Lane\x1b[37m.\n\x1b[0;32;40mYou are on a dusty road which disappears into olive groves up a hill to the southeast, and continues to the north. To the west is an ancient farm building, and to the northwest are fields. A tall hedge obstructs most of the view to the east, but a gap leads into a yard. \x1b[1;37;40m\n\x1b[0;34'
...
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.