MudGym¶
A reinforcement learning environment for MUD2.
The game engine is packaged as WebAssembly (WASM). Native Python runs it using wasmtime, while the JupyterLite notebook runs in your browser using Pyodide with no install required.
Local Setup¶
Install the mudgym package with your Python package manager of choice.
Single Agent¶
from mudgym import make_env
env = make_env()
observation, info = env.reset()
observation, reward, terminated, truncated, info = env.step("l,howl")
env.close()
Dally Lane.
You 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. It is raining.
You howl.
Multi-agent (MARL)¶
Two agents in the same world.
from mudgym import make_parallel_env
env = make_parallel_env(agents=2)
obs, infos = env.reset()
actions = dict.fromkeys(env.agents, "yodel")
obs, rewards, terminates, truncates, infos = env.step(actions)
for agent in sorted(obs):
print(agent, obs[agent]["room_name"], rewards[agent])
env.close()
player_0
You yodel.
A female voice in the distance yodels.
player_1
A male voice in the distance yodels.
You yodel.
License¶
The Python code and tooling in this repository are MIT licensed.
The MUD2 game, name, source code, and associated story remain the intellectual property of Richard Bartle and Roy Trubshaw and may not be used for commercial purposes.
Permission to use the MUD2 game for research purposes has been provided by Richard Bartle, with kind thanks.