Open world survival environment for reinforcement learning

Overview

Crafter

PyPI

Open world survival environment for reinforcement learning.

Crafter Terrain

Highlights

Crafter is a procedurally generated 2D world, where the agent finds food, avoids or defends against zombies, and collect materials to build tools, which in turn unlock new materials.

  • Generalization: New procedurally generated map for each episode.
  • Exploration: Materials unlock new tools which unlock new materials.
  • Memory: Input images show small part of the world centered at the agent.
  • No trivial behaviors: Must find food and avoid or defend against zombies.
  • Easy: Flat categorical action space with 12 actions.
  • Fast: Runs at 2000 FPS on a simple laptop.
  • Reproducible: All randomness is controlled by a seed.

Play Yourself

You can play the game yourself with an interactive window and keyboard input. The mapping from keys to actions, health level, and inventory state are printed to the terminal.

# Install with GUI
pip3 install 'crafter[gui]'

# Start the game
crafter

# Alternative way to start the game
python3 -m crafter.run_gui

Crafter Video

The following optional command line flags are available:

Flag Default Description
--window <size> 800 Window size in pixels, used as width and height.
--fps <integer> 5 How many times to update the environment per second.
--record <filename>.mp4 None Record a video of the trajectory.
--area <width> <height> 64 64 The size of the world in cells.
--view <distance> 6 The view distance of the player in cells.
--length <integer> None Time limit for the episode.
--seed <integer> None Determines world generation and creatures.

Training Agents

Installation: pip3 install -U crafter

The environment follows the OpenAI Gym interface:

import crafter

env = crafter.Env(seed=0)
obs = env.reset()
assert obs['image'].shape == (64, 64, 3)

done = False
while not done:
  action = env.action_space.sample()
  obs, reward, done, info = env.step(action)

Environment Details

Constructor

For comparability between papers, we recommend using the environment in its default configuration. Nonetheless, the environment can be configured via its constructor:

crafter.Env(area=(64, 64), view=4, size=64, length=10000, seed=None)
Parameter Default Description
area (64, 64) Size of the world in cells.
view 4 View distance of the player in cells.
size 64 Render size of the images, used for both width and height.
length 10000 Time limit for the episode, can be None.
health 10 Initial health level of the player.
seed None Interger that determines world generation and creatures.

Reward

The reward is sparse. It can either be given to the agent or used as a proxy metric for evaluating unsupervised agents. The reward is 1 when the agent unlocks a new achievement and 0 for all other time steps. The list of achievements is as follows:

  • find_food
  • defeat_zombie
  • collect_wood
  • place_table
  • make_wood_pickaxe
  • collect_stone
  • place_stone
  • make_stone_pickaxe
  • collect_coal
  • collect_iron
  • place_furnace
  • make_iron_pickaxe
  • collect_diamond

The set of unlocked achievements can also be accessed via the info dictionary.

Termination

The episode terminates when the health points of the agent reach zero. Episodes also end when reaching a time limit, which is 100,000 steps by default.

Observation Space

Each observation is a dictionary that contains a local image centered at the agent and counters for player health and inventory. The following keys are available:

Key Space
image Box(0, 255, (64, 64, 3), np.uint8)
health Box(0, 255, (), np.uint8)
wood Box(0, 255, (), np.uint8)
stone Box(0, 255, (), np.uint8)
iron Box(0, 255, (), np.uint8)
diamond Box(0, 255, (), np.uint8)
wood_pickaxe Box(0, 255, (), np.uint8)
stone_pickaxe Box(0, 255, (), np.uint8)
iron_pickaxe Box(0, 255, (), np.uint8)

Action Space

The action space is categorical. Each action is an integer index representing one of the 12 possible actions:

Integer Name Requirement
0 noop Always applicable.
1 left Flat ground left to the agent.
2 right Flat ground right to the agent.
3 up Flat ground above the agent.
4 down Flat ground below the agent.
5 grab_or_attack Facing creature or material and has necessary tool.
6 place_stone Stone in inventory.
7 place_table Wood in inventory.
8 place_furnace Stone in inventory.
9 make_wood_pickaxe Nearby table and wood in inventory.
10 make_stone_pickaxe Nearby tabel and wood, stone in inventory.
11 make_iron_pickaxe Nearby furnace and wood, coal, iron an inventory.

Questions

Please open an issue on Github.

Owner
Danijar Hafner
I'm trying to build unsupervised intelligent machines and evaluate them in complex environments.
Danijar Hafner
A toolkit for developing and comparing reinforcement learning algorithms.

Status: Maintenance (expect bug fixes and minor updates) OpenAI Gym OpenAI Gym is a toolkit for developing and comparing reinforcement learning algori

OpenAI 29.6k Jan 01, 2023
A fork of OpenAI Baselines, implementations of reinforcement learning algorithms

Stable Baselines Stable Baselines is a set of improved implementations of reinforcement learning algorithms based on OpenAI Baselines. You can read a

Ashley Hill 3.7k Jan 01, 2023
Open world survival environment for reinforcement learning

Crafter Open world survival environment for reinforcement learning. Highlights Crafter is a procedurally generated 2D world, where the agent finds foo

Danijar Hafner 213 Jan 05, 2023
Tensorforce: a TensorFlow library for applied reinforcement learning

Tensorforce: a TensorFlow library for applied reinforcement learning Introduction Tensorforce is an open-source deep reinforcement learning framework,

Tensorforce 3.2k Jan 02, 2023
A general-purpose multi-agent training framework.

MALib A general-purpose multi-agent training framework. Installation step1: build environment conda create -n malib python==3.7 -y conda activate mali

MARL @ SJTU 346 Jan 03, 2023
Monitor your el-cheapo UPS via SNMP

UPSC-SNMP-Agent UPSC-SNMP-Agent exposes your el-cheapo locally connected UPS via the SNMP network management protocol. This enables various equipment

Tom Szilagyi 32 Jul 28, 2022
A customisable 3D platform for agent-based AI research

DeepMind Lab is a 3D learning environment based on id Software's Quake III Arena via ioquake3 and other open source software. DeepMind Lab provides a

DeepMind 6.8k Jan 05, 2023
Game Agent Framework. Helping you create AIs / Bots that learn to play any game you own!

Serpent.AI - Game Agent Framework (Python) Update: Revival (May 2020) Development work has resumed on the framework with the aim of bringing it into 2

Serpent.AI 6.4k Jan 05, 2023
Retro Games in Gym

Status: Maintenance (expect bug fixes and minor updates) Gym Retro Gym Retro lets you turn classic video games into Gym environments for reinforcement

OpenAI 2.8k Jan 03, 2023
Dopamine is a research framework for fast prototyping of reinforcement learning algorithms.

Dopamine Dopamine is a research framework for fast prototyping of reinforcement learning algorithms. It aims to fill the need for a small, easily grok

Google 10k Jan 07, 2023
Doom-based AI Research Platform for Reinforcement Learning from Raw Visual Information. :godmode:

ViZDoom ViZDoom allows developing AI bots that play Doom using only the visual information (the screen buffer). It is primarily intended for research

Marek Wydmuch 1.5k Dec 30, 2022
Rethinking the Importance of Implementation Tricks in Multi-Agent Reinforcement Learning

MARL Tricks Our codes for RIIT: Rethinking the Importance of Implementation Tricks in Multi-AgentReinforcement Learning. We implemented and standardiz

404 Dec 25, 2022
Paddle-RLBooks is a reinforcement learning code study guide based on pure PaddlePaddle.

Paddle-RLBooks Welcome to Paddle-RLBooks which is a reinforcement learning code study guide based on pure PaddlePaddle. 欢迎来到Paddle-RLBooks,该仓库主要是针对强化学

AgentMaker 117 Dec 12, 2022
TF-Agents: A reliable, scalable and easy to use TensorFlow library for Contextual Bandits and Reinforcement Learning.

TF-Agents: A reliable, scalable and easy to use TensorFlow library for Contextual Bandits and Reinforcement Learning. TF-Agents makes implementing, de

2.4k Dec 29, 2022
Deep Reinforcement Learning for Keras.

Deep Reinforcement Learning for Keras What is it? keras-rl implements some state-of-the art deep reinforcement learning algorithms in Python and seaml

Keras-RL 5.4k Jan 04, 2023
ChainerRL is a deep reinforcement learning library built on top of Chainer.

ChainerRL ChainerRL is a deep reinforcement learning library that implements various state-of-the-art deep reinforcement algorithms in Python using Ch

Chainer 1.1k Dec 26, 2022
A toolkit for reproducible reinforcement learning research.

garage garage is a toolkit for developing and evaluating reinforcement learning algorithms, and an accompanying library of state-of-the-art implementa

Reinforcement Learning Working Group 1.6k Jan 09, 2023
Modular Deep Reinforcement Learning framework in PyTorch. Companion library of the book "Foundations of Deep Reinforcement Learning".

SLM Lab Modular Deep Reinforcement Learning framework in PyTorch. Documentation: https://slm-lab.gitbook.io/slm-lab/ BeamRider Breakout KungFuMaster M

Wah Loon Keng 1.1k Dec 24, 2022
A platform for Reasoning systems (Reinforcement Learning, Contextual Bandits, etc.)

Applied Reinforcement Learning @ Facebook Overview ReAgent is an open source end-to-end platform for applied reinforcement learning (RL) developed and

Facebook Research 3.3k Jan 05, 2023