This project contains small games for testing how an agent can learn a world model only by interacting with an environment.
The intended setting is that the model has no prior explanation of the game rules. It receives observations, chooses actions, sees rewards, and must infer the transition dynamics from experience.
Each game lives in games/ and is split into two files:
<game>.py: the executable Gym-style environment<game>.md: a human-readable game specification with examples
Each agent lives in agents/:
<agent>.py: an agent implementation that exposes anAgentclass
Current games:
- Word World: a one-dimensional string game where the player moves left or right, collects targets, and grows.
Current agents:
random_agent: samples uniformly from the game's action space.
Games should follow the Gymnasium-style API:
state, info = env.reset(seed=123)
state, reward, terminated, truncated, info = env.step(action)The public loop should expose only the current state and reward to avoid giving away rule names through metadata.
Run the current game with:
python -m games.word_worldThe command prints lines like:
state=-----+--------0------+---+---- reward=0.0
state=-----+-------0-------+---+---- reward=-1.0
Run an agent against a game with:
python evaluate.py random_agent word_worldThe script prints an aggregate score:
agent=random_agent
game=word_world
episodes=20
score=-66.700
completed=7
completion_rate=0.350
best_reward=2.000
worst_reward=-118.000
from games.word_world import LEFT, RIGHT, WordWorldEnv
env = WordWorldEnv()
state, info = env.reset()
state, reward, terminated, truncated, info = env.step(LEFT)Seeded random initialization is available:
env = WordWorldEnv.random(width=30, food_count=3, seed=100)
state, info = env.reset(seed=42)To add a new game:
- Add
games/<game_name>.py. - Add
games/<game_name>.md. - Keep the environment API compatible with
resetandstep. - Make the runnable game output only state and reward.
- Add focused tests for reset, transitions, rewards, and episode endings.
To add a new agent:
- Add
agents/<agent_name>.py. - Define an
Agentclass. - Accept
action_spaceand an optionalseedin__init__. - Implement
act(state, reward=0.0). - Optionally implement
reset()for per-episode state.
The experiments compare how efficiently different agents learn an accurate world model. Useful measurements include:
- how many interaction steps are needed before predictions become accurate
- how well another algorithm can use the learned model to plan for reward
- how robust the learned model is across seeded game initializations
The first game is intentionally text-based so an LLM can perceive the full state directly. Later experiments can add more games while keeping the same interaction pattern.