Multi-Environment MiniGrid World Models

Riju Mukherjee, Kurt Driessens, Dennis J. N. J. SoemersBNAIC/BeNeLearn 2025

TL;DR

This paper explores how reinforcement learning agents can learn to generalize and transfer knowledge across multiple environments simultaneously using "world models." They found that training agents on a diverse set of simple grid-world tasks with shared parameters leads to more sample-efficient learning and better adaptation to new, slightly modified environments.

What Problem Does This Paper Address?

Reinforcement learning (RL) agents often struggle with generalization and transfer learning – the ability to apply knowledge learned in one task or environment to new, unseen ones. This is a major bottleneck for their real-world applicability, as current RL agents typically require extensive retraining for each new scenario. Humans, on the other hand, excel at this, leveraging internal "world models" (akin to cognitive maps) to understand and adapt to novel situations efficiently. This paper investigates whether building such world models within RL agents can imbue them with similar generalization capabilities, particularly when trained across multiple, diverse environments concurrently.

Methods

The core of this work lies in exploring two distinct world model architectures for RL agents:

  • STORM (Stochastic Transformer-based World Model): This serves as the baseline. It uses a Variational Auto-Encoder (VAE) to encode observations into stochastic categorical distributions, which are then processed by a transformer-based sequence model. This model predicts future states, rewards, and episode continuations.
  • TEM Transformer: This is a novel, hippocampus-inspired variant of the transformer. It processes spatial (position) and stimulus (observation) information in parallel streams, allowing for a more integrated representation of the environment. The authors adapted the original TEM transformer for sequence modeling within a world model context, replacing its simple recurrent update for position encodings with a Gated Recurrent Unit (GRU) for potentially more expressive representations.

The agent's policy (actor-critic) is trained using the latent representations generated by these world models. The key experimental setup involves training a single agent with shared parameters across multiple environments simultaneously, and then evaluating its performance and transfer capabilities.

Datasets

The experiments were conducted using a suite of simple, goal-oriented 2D grid-world environments from the MiniGrid framework. Four specific environments were chosen:

  • Empty: A basic goal-reaching task.
  • Simple Crossing: Similar to Empty but with obstacles and a single opening.
  • Four Rooms: A more complex maze requiring navigation through multiple interconnected rooms.
  • Memory: A task that tests the agent's ability to remember an object and find a matching one later.

Each of these environments was used in both fully observable and partially observable variants. Additionally, the authors created modified versions of the "Empty" environment (e.g., Empty-FullObs-Ort-1) by rotating the agent and goal positions to specifically test for spatial invariance.

Key Insights and Ideas

  • Multi-environment training fosters generalization: Training a single agent on a diverse set of environments simultaneously, with shared parameters, leads to better performance and faster learning compared to training agents independently on each environment.
  • World models as a bridge for generalization: The use of world models, particularly the TEM transformer variant, appears to be crucial in enabling agents to learn abstract representations that facilitate generalization.
  • Hippocampus inspiration pays off: The TEM transformer, inspired by the hippocampus, shows promising results, especially in its ability to potentially learn more robust spatial representations.
  • Spatial invariance is testable: The creation of rotated "Empty" environments allowed for a direct evaluation of the agent's ability to handle spatial transformations, demonstrating a form of transfer.
  • Latent space separation indicates learning: t-SNE visualizations of the learned latent representations show that the agent effectively learns to distinguish between different environments as training progresses, forming distinct clusters.

Key Results

  • Improved sample efficiency: Multi-environment agents (MEAs) trained with both STORM and TEM transformers achieved significantly higher episodic returns in less training time compared to single-environment agents (SEAs) across most environments.
  • Solvable tasks: In fully observable settings, MEAs successfully learned optimal policies in "Empty" and "Simple Crossing."
  • Partial success in complex tasks: While "Memory" and "Four Rooms" presented challenges, the TEM transformer showed some improvement in making "Memory" solvable, though this requires further investigation.
  • Faster adaptation to spatial variations: When transferred to rotated "Empty" environments, agents with pre-trained world models and actor-critics learned optimal policies in under 50 steps, significantly faster than training from scratch. This indicates helpful transfer.
  • Latent space clustering: t-SNE plots confirmed that the learned latent representations of environments become increasingly separated as training progresses, suggesting the agent is learning distinct environmental features.

Limitations and Future Work

  • "Four Rooms" remains challenging: The current approaches struggled to consistently solve the "Four Rooms" environment, suggesting that more advanced techniques, like hierarchical RL, might be necessary.
  • TEM transformer advantage needs more validation: While the TEM transformer showed some promise, particularly in the "Memory" environment, the authors note that further research with more random seeds is needed to conclusively attribute these improvements to the modified architecture.
  • Clean separation vs. transfer: The clear separation of environment clusters in the t-SNE plots, while indicating good learning, might also suggest a lack of deep transfer between environments.
  • Future directions: The authors suggest exploring more extensive environment variations, incorporating more "in-between" environments to bridge transfer gaps, and investigating architectural additions like Mixture-of-Experts or hierarchical RL support for world models to enhance generalization and transfer capabilities.

Summary updated

BibTeX
@inproceedings{mukherjee2025multi,
  author = {Riju Mukherjee and Kurt Driessens and Dennis J. N. J. Soemers},
  title = {{Multi-Environment MiniGrid World Models}},
  booktitle = {BNAIC/BeNeLearn},
  year = {2025},
  url = {https://openreview.net/forum?id=6imm03HlkZ},
}
Figure