Home

Awesome

<p align="center"> <a href="docs/img/jumanji_logo.png"> <img src="docs/img/jumanji_logo.png" alt="Jumanji logo" width="50%"/> </a> </p>

Python Versions PyPI Version Tests Code Style MyPy License Hugging Face

Environments | Installation | Quickstart | Training | Citation | Docs

<div class="collage"> <div class="row" align="center"> <img src="docs/env_anim/bin_pack.gif" alt="BinPack" width="16%"> <img src="docs/env_anim/cleaner.gif" alt="Cleaner" width="16%"> <img src="docs/env_anim/connector.gif" alt="Connector" width="16%"> <img src="docs/env_anim/cvrp.gif" alt="CVRP" width="16%"> <img src="docs/env_anim/flat_pack.gif" alt="FlatPack" width="16%"> <img src="docs/env_anim/game_2048.gif" alt="Game2048" width="16%"> </div> <div class="row" align="center"> <img src="docs/env_anim/graph_coloring.gif" alt="GraphColoring" width="16%"> <img src="docs/env_anim/job_shop.gif" alt="JobShop" width="16%"> <img src="docs/env_anim/knapsack.gif" alt="Knapsack" width="16%"> <img src="docs/env_anim/maze.gif" alt="Maze" width="16%"> <img src="docs/env_anim/minesweeper.gif" alt="Minesweeper" width="16%"> <img src="docs/env_anim/mmst.gif" alt="MMST" width="16%"> </div> <div class="row" align="center"> <img src="docs/env_anim/multi_cvrp.gif" alt="MultiCVRP" width="16%"> <img src="docs/env_anim/pac_man.gif" alt="PacMan" width="12.9%"> <img src="docs/env_anim/robot_warehouse.gif" alt="RobotWarehouse" width="16%"> <img src="docs/env_anim/rubiks_cube.gif" alt="RubiksCube" width="16%"> <img src="docs/env_anim/sliding_tile_puzzle.gif" alt="SlidingTilePuzzle" width="16%"> <img src="docs/env_anim/snake.gif" alt="Snake" width="16%"> </div> <div class="row" align="center"> <img src="docs/env_anim/sokoban.gif" alt="RobotWarehouse" width="16%"> <img src="docs/env_anim/sudoku.gif" alt="Sudoku" width="16%"> <img src="docs/env_anim/tetris.gif" alt="Tetris" width="16%"> <img src="docs/env_anim/tsp.gif" alt="Tetris" width="16%"> <img src="docs/env_anim/lbf.gif" alt="Level-Based Foraging" width="16%"> </div> </div>

Jumanji @ ICLR 2024

Jumanji has been accepted at ICLR 2024, check out our research paper.

Welcome to the Jungle! 🌴

Jumanji is a diverse suite of scalable reinforcement learning environments written in JAX. It now features 22 environments!

Jumanji is helping pioneer a new wave of hardware-accelerated research and development in the field of RL. Jumanji's high-speed environments enable faster iteration and large-scale experimentation while simultaneously reducing complexity. Originating in the research team at InstaDeep, Jumanji is now developed jointly with the open-source community. To join us in these efforts, reach out, raise issues and read our contribution guidelines or just star 🌟 to stay up to date with the latest developments!

Goals πŸš€

  1. Provide a simple, well-tested API for JAX-based environments.
  2. Make research in RL more accessible.
  3. Facilitate the research on RL for problems in the industry and help close the gap between research and industrial applications.
  4. Provide environments whose difficulty can be scaled to be arbitrarily hard.

Overview 🦜

<h2 name="environments" id="environments">Environments 🌍</h2>

Jumanji provides a diverse range of environments ranging from simple games to NP-hard combinatorial problems.

EnvironmentCategoryRegistered Version(s)SourceDescription
πŸ”’ Game2048LogicGame2048-v1codedoc
🎨 GraphColoringLogicGraphColoring-v0codedoc
πŸ’£ MinesweeperLogicMinesweeper-v0codedoc
🎲 RubiksCubeLogicRubiksCube-v0<br/>RubiksCube-partly-scrambled-v0codedoc
πŸ”€ SlidingTilePuzzleLogicSlidingTilePuzzle-v0codedoc
✏️ SudokuLogicSudoku-v0 <br/>Sudoku-very-easy-v0codedoc
πŸ“¦ BinPack (3D BinPacking Problem)PackingBinPack-v1codedoc
🧩 FlatPack (2D Grid Filling Problem)PackingFlatPack-v0codedoc
🏭 JobShop (Job Shop Scheduling Problem)PackingJobShop-v0codedoc
πŸŽ’ KnapsackPackingKnapsack-v1codedoc
β–’ TetrisPackingTetris-v0codedoc
🧹 CleanerRoutingCleaner-v0codedoc
:link: ConnectorRoutingConnector-v2codedoc
🚚 CVRP (Capacitated Vehicle Routing Problem)RoutingCVRP-v1codedoc
🚚 MultiCVRP (Multi-Agent Capacitated Vehicle Routing Problem)RoutingMultiCVRP-v0codedoc
:mag: MazeRoutingMaze-v0codedoc
:robot: RobotWarehouseRoutingRobotWarehouse-v0codedoc
🐍 SnakeRoutingSnake-v1codedoc
πŸ“¬ TSP (Travelling Salesman Problem)RoutingTSP-v1codedoc
Multi Minimum Spanning Tree ProblemRoutingMMST-v0codedoc
α—§β€’β€’β€’α—£β€’β€’ PacManRoutingPacMan-v1codedoc
πŸ‘Ύ SokobanRoutingSokoban-v0codedoc
🍎 Level-Based ForagingRoutingLevelBasedForaging-v0codedoc
<h2 name="install" id="install">Installation 🎬</h2>

You can install the latest release of Jumanji from PyPI:

pip install -U jumanji

Alternatively, you can install the latest development version directly from GitHub:

pip install git+https://github.com/instadeepai/jumanji.git

Jumanji has been tested on Python 3.10, 3.11 and 3.12. Note that because the installation of JAX differs depending on your hardware accelerator, we advise users to explicitly install the correct JAX version (see the official installation guide).

Rendering: Matplotlib is used for rendering all the environments. To visualize the environments you will need a GUI backend. For example, on Linux, you can install Tk via: apt-get install python3-tk, or using conda: conda install tk. Check out Matplotlib backends for a list of backends you can use.

<h2 name="quickstart" id="quickstart">Quickstart ⚑</h2>

RL practitioners will find Jumanji's interface familiar as it combines the widely adopted OpenAI Gym and DeepMind Environment interfaces. From OpenAI Gym, we adopted the idea of a registry and the render method, while our TimeStep structure is inspired by DeepMind Environment.

Basic Usage πŸ§‘β€πŸ’»

import jax
import jumanji

# Instantiate a Jumanji environment using the registry
env = jumanji.make('Snake-v1')

# Reset your (jit-able) environment
key = jax.random.PRNGKey(0)
state, timestep = jax.jit(env.reset)(key)

# (Optional) Render the env state
env.render(state)

# Interact with the (jit-able) environment
action = env.action_spec.generate_value()          # Action selection (dummy value here)
state, timestep = jax.jit(env.step)(state, action)   # Take a step and observe the next state and time step

Advanced Usage πŸ§‘β€πŸ”¬

Being written in JAX, Jumanji's environments benefit from many of its features including automatic vectorization/parallelization (jax.vmap, jax.pmap) and JIT-compilation (jax.jit), which can be composed arbitrarily. We provide an example of a more advanced usage in the advanced usage guide.

Registry and Versioning πŸ“–

Like OpenAI Gym, Jumanji keeps a strict versioning of its environments for reproducibility reasons. We maintain a registry of standard environments with their configuration. For each environment, a version suffix is appended, e.g. Snake-v1. When changes are made to environments that might impact learning results, the version number is incremented by one to prevent potential confusion. For a full list of registered versions of each environment, check out the documentation.

<h2 name="training" id="training">Training 🏎️</h2>

To showcase how to train RL agents on Jumanji environments, we provide a random agent and a vanilla actor-critic (A2C) agent. These agents can be found in jumanji/training/.

Because the environment framework in Jumanji is so flexible, it allows pretty much any problem to be implemented as a Jumanji environment, giving rise to very diverse observations. For this reason, environment-specific networks are required to capture the symmetries of each environment. Alongside the A2C agent implementation, we provide examples of such environment-specific actor-critic networks in jumanji/training/networks.

⚠️ The example agents in jumanji/training are only meant to serve as inspiration for how one can implement an agent. Jumanji is first and foremost a library of environments - as such, the agents and networks will not be maintained to a production standard.

For more information on how to use the example agents, see the training guide.

Contributing 🀝

Contributions are welcome! See our issue tracker for good first issues. Please read our contributing guidelines for details on how to submit pull requests, our Contributor License Agreement, and community guidelines.

<h2 name="citing" id="citing">Citing Jumanji ✏️</h2>

If you use Jumanji in your work, please cite the library using:

@misc{bonnet2024jumanji,
    title={Jumanji: a Diverse Suite of Scalable Reinforcement Learning Environments in JAX},
    author={ClΓ©ment Bonnet and Daniel Luo and Donal Byrne and Shikha Surana and Sasha Abramowitz and Paul Duckworth and Vincent Coyette and Laurence I. Midgley and Elshadai Tegegn and Tristan Kalloniatis and Omayma Mahjoub and Matthew Macfarlane and Andries P. Smit and Nathan Grinsztajn and Raphael Boige and Cemlyn N. Waters and Mohamed A. Mimouni and Ulrich A. Mbou Sob and Ruan de Kock and Siddarth Singh and Daniel Furelos-Blanco and Victor Le and Arnu Pretorius and Alexandre Laterre},
    year={2024},
    eprint={2306.09884},
    url={https://arxiv.org/abs/2306.09884},
    archivePrefix={arXiv},
    primaryClass={cs.LG}
}

See Also πŸ”Ž

Other works have embraced the approach of writing RL environments in JAX. In particular, we suggest users check out the following sister repositories:

Acknowledgements πŸ™

The development of this library was supported with Cloud TPUs from Google's TPU Research Cloud (TRC) 🌀.