Skip to main content

NetHack Learning Environment (NLE)


Twitter

The NetHack Learning Environment (NLE) is a Reinforcement Learning environment presented at NeurIPS 2020. NLE is based on NetHack 3.6.6 and designed to provide a standard RL interface to the game, and comes with tasks that function as a first step to evaluate agents on this new environment.

NetHack is one of the oldest and arguably most impactful videogames in history, as well as being one of the hardest roguelikes currently being played by humans. It is procedurally generated, rich in entities and dynamics, and overall an extremely challenging environment for current state-of-the-art RL agents, while being much cheaper to run compared to other challenging testbeds. Through NLE, we wish to establish NetHack as one of the next challenges for research in decision making and machine learning.

You can read more about NLE in the NeurIPS 2020 paper, and about NetHack in its original README, at nethack.org, and on the NetHack wiki.

Example of an agent running on NLE

NLE Language Wrapper

We thank ngoodger for implementing the NLE Language Wrapper that translates the non-language observations from NetHack tasks into similar language representations. Actions can also be optionally provided in text form which are converted to the Discrete actions of the NLE.

NetHack Learning Dataset

The NetHack Learning Dataset (NLD) code now ships with NLE, allowing users to the load large-scale datasets featured in Dungeons and Data: A Large-Scale NetHack Dataset, while also generating and loading their own datasets.

import nle.dataset as nld

if not nld.db.exists():
    nld.db.create()
    # NB: Different methods are used for data based on NLE and data from NAO.
    nld.add_nledata_directory("/path/to/nld-aa", "nld-aa-v0")
    nld.add_altorg_directory("/path/to/nld-nao", "nld-nao-v0")

dataset = nld.TtyrecDataset("nld-aa-v0", batch_size=128, ...)
for i, mb in enumerate(dataset):
    foo(mb) # etc...

For information on how to download NLD-AA and NLD-NAO, see the dataset doc here.

Otherwise checkout the tutorial Colab notebook here.

Papers using the NetHack Learning Environment

Open a pull request to add papers.

Getting started

Starting with NLE environments is extremely simple, provided one is familiar with other gym / RL environments.

Installation

NLE requires python>=3.5, cmake>=3.15 to be installed and available both when building the package, and at runtime.

On MacOS, one can use Homebrew as follows:

$ brew install cmake

On a plain Ubuntu 18.04 distribution, cmake and other dependencies can be installed by doing:

# Python and most build deps
$ sudo apt-get install -y build-essential autoconf libtool pkg-config \
    python3-dev python3-pip python3-numpy git flex bison libbz2-dev

# recent cmake version
$ wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo apt-key add -
$ sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main'
$ sudo apt-get update && apt-get --allow-unauthenticated install -y \
    cmake \
    kitware-archive-keyring

Afterwards it's a matter of setting up your environment. We advise using a conda environment for this:

$ conda create -y -n nle python=3.8
$ conda activate nle
$ pip install nle

NOTE: If you want to extend / develop NLE, please install the package as follows:

$ git clone https://github.com/facebookresearch/nle --recursive
$ pip install -e ".[dev]"
$ pre-commit install

Docker

We have provided some docker images. Please see the relevant README.

Trying it out

After installation, one can try out any of the provided tasks as follows:

>>> import gym
>>> import nle
>>> env = gym.make("NetHackScore-v0")
>>> env.reset()  # each reset generates a new dungeon
>>> env.step(1)  # move agent '@' north
>>> env.render()

NLE also comes with a few scripts that allow to get some environment rollouts, and play with the action space:

# Play NetHackStaircase-v0 as a human
$ python -m nle.scripts.play

# Use a random agent
$ python -m nle.scripts.play --mode random

# Play the full game using directly the NetHack internal interface
# (Useful for debugging outside of the gym environment)
$ python -m nle.scripts.play --env NetHackScore-v0 # works with random agent too

# See all the options
$ python -m nle.scripts.play --help

Note that nle.scripts.play can also be run with nle-play, if the package has been properly installed.

Additionally, a TorchBeast agent is bundled in nle.agent together with a simple model to provide a starting point for experiments:

$ pip install "nle[agent]"
$ python -m nle.agent.agent --num_actors 80 --batch_size 32 --unroll_length 80 --learning_rate 0.0001 --entropy_cost 0.0001 --use_lstm --total_steps 1000000000

Plot the mean return over the last 100 episodes:

$ python -m nle.scripts.plot
                              averaged episode return

  140 +---------------------------------------------------------------------+
      |             +             +            ++-+ ++++++++++++++++++++++++|
      |             :             :          ++++++++||||||||||||||||||||||||
  120 |-+...........:.............:...+-+.++++|||||||||||||||||||||||||||||||
      |             :        +++++++++++++++||||||||||AAAAAAAAAAAAAAAAAAAAAA|
      |            +++++++++++++||||||||||||||AAAAAAAAAAAA|||||||||||||||||||
  100 |-+......+++++|+|||||||||||||||||||||||AA||||||||||||||||||||||||||||||
      |       +++|||||||||||||||AAAAAAAAAAAAAA|||||||||||+++++++++++++++++++|
      |    ++++|||||AAAAAAAAAAAAAA||||||||||||++++++++++++++-+:             |
   80 |-++++|||||AAAAAA|||||||||||||||||||||+++++-+...........:...........+-|
      | ++|||||AAA|||||||||||||||++++++++++++-+ :             :             |
   60 |++||AAAAA|||||+++++++++++++-+............:.............:...........+-|
      |++|AA||||++++++-|-+        :             :             :             |
      |+|AA|||+++-+ :             :             :             :             |
   40 |+|A+++++-+...:.............:.............:.............:...........+-|
      |+AA+-+       :             :             :             :             |
      |AA-+         :             :             :             :             |
   20 |AA-+.........:.............:.............:.............:...........+-|
      |++-+         :             :             :             :             |
      |+-+          :             :             :             :             |
    0 |-+...........:.............:.............:.............:...........+-|
      |+            :             :             :             :             |
      |+            +             +             +             +             |
  -20 +---------------------------------------------------------------------+
      0           2e+08         4e+08         6e+08         8e+08         1e+09
                                       steps

Contributing

We welcome contributions to NLE. If you are interested in contributing please see this document.

Architecture

NLE is direct fork of NetHack and therefore contains code that operates on many different levels of abstraction. This ranges from low-level game logic, to the higher-level administration of repeated nethack games, and finally to binding of these games to Python gym environment.

If you want to learn more about the architecture of nle and how it works under the hood, checkout the architecture document. This may be a useful starting point for anyone looking to contribute to the lower level elements of NLE.

Related Environments

Interview about the environment with Weights&Biases

Facebook AI Research’s Tim & Heiner on democratizing reinforcement learning research.

Interview with Weigths&Biases

Citation

If you use NLE in any of your work, please cite:

@inproceedings{kuettler2020nethack,
  author    = {Heinrich K{\"{u}}ttler and
               Nantas Nardelli and
               Alexander H. Miller and
               Roberta Raileanu and
               Marco Selvatici and
               Edward Grefenstette and
               Tim Rockt{\"{a}}schel},
  title     = {{The NetHack Learning Environment}},
  booktitle = {Proceedings of the Conference on Neural Information Processing Systems (NeurIPS)},
  year      = {2020},
}

If you use NLD or the datasets in any of your work, please cite:

@inproceedings{hambro2022dungeonsanddata,
  author    = {Eric Hambro and
               Roberta Raileanu and
               Danielle Rothermel and
               Vegard Mella and
               Tim Rockt{\"{a}}schel and
               Heinrich K{\"{u}}ttler and
               Naila Murray},
  title     = {{Dungeons and Data: A Large-Scale NetHack Dataset}},
  booktitle = {Thirty-sixth Conference on Neural Information Processing Systems Datasets and Benchmarks Track},
  year      = {2022},
  url       = {https://openreview.net/forum?id=zHNNSzo10xN}
}

Metadata

Release files for balrog-nle 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for balrog-nle 0.9.0
File Size Uploaded Provenance
balrog_nle-0.9.0.tar.gz 7.4 MB Without provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for balrog-nle 0.9.0
File
balrog_nle-0.9.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details
balrog_nle-0.9.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ ARM64 Details
balrog_nle-0.9.0-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
balrog_nle-0.9.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details
balrog_nle-0.9.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ ARM64 Details
balrog_nle-0.9.0-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details
balrog_nle-0.9.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details
balrog_nle-0.9.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ ARM64 Details
balrog_nle-0.9.0-cp39-cp39-macosx_11_0_arm64.whl CPython 3.9 CPython 3.9 macOS 11.0+ ARM64 Details
balrog_nle-0.9.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.17+ x86-64 Details
balrog_nle-0.9.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.8 CPython 3.8 Linux glibc 2.17+ ARM64 Details
balrog_nle-0.9.0-cp38-cp38-macosx_10_9_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.9+ x86-64 Details

Total release size: 45.0 MB

Release files / balrog_nle-0.9.0.tar.gz

Download URL balrog_nle-0.9.0.tar.gz
Size 7.4 MB
Tags Source
SHA-256 checksum
How to use checksums
10cd24d8483353ceb58c8c817d5134bc6edd60017a0f71dc465031bfeb66b957
BLAKE2b-256 checksum
How to use checksums
743da1a258ec07611cd48a25955b6537d63a8afb2db1b1fa7fc436b3878c5b8d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Release files / balrog_nle-0.9.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL balrog_nle-0.9.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.3 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
45ea0ef8fca88fea39f7079b1678aa7d1b73a070bee4140fcb9f3ad26906f7e2
BLAKE2b-256 checksum
How to use checksums
eb499bb0190fb34f290c1e4a60ef7fa64aa749bc4f53cc9c1085aa3b2511fe11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Release files / balrog_nle-0.9.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL balrog_nle-0.9.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 3.2 MB
Tags CPython 3.11 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
87e2dd898af014a8f86a4dbfbf1273f7d4b525d727933a4a5e2901c9ee2393aa
BLAKE2b-256 checksum
How to use checksums
911e09abcb7fee06476cff9f0412ac1538c16a16055714a8c587926d3e26ab3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Release files / balrog_nle-0.9.0-cp311-cp311-macosx_11_0_arm64.whl

Download URL balrog_nle-0.9.0-cp311-cp311-macosx_11_0_arm64.whl
Size 2.9 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
18b0f36288d34f5308c4a9c0072887e9c005afdb336f60b5b6f6fa39a64313a7
BLAKE2b-256 checksum
How to use checksums
2d7d98507367213c0eec78790878559fbc703cca9489e62ec7c9f30cd9c967ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Release files / balrog_nle-0.9.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL balrog_nle-0.9.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.3 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
b5a6ba1e6a7c406e7918e56f525937919bad6c8ec68df9ca2acbb6714e55dcd2
BLAKE2b-256 checksum
How to use checksums
90e33ea90f299b64b4896d3767ecac848304e9a96478f8164ad2cbb7da5a3323
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Release files / balrog_nle-0.9.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL balrog_nle-0.9.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 3.2 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
9e31c7b014834db98425681b8af4b2cd8751bda0347338d230c60cd882c8d8e5
BLAKE2b-256 checksum
How to use checksums
faf01163b0ffef74dc050041ebc26bb44447573c397fdbccc80c646c55a7abc3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Release files / balrog_nle-0.9.0-cp310-cp310-macosx_11_0_arm64.whl

Download URL balrog_nle-0.9.0-cp310-cp310-macosx_11_0_arm64.whl
Size 2.8 MB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2018e8c373b7783574e90948b5a2cd6ea425653d3512c7089e21e33ffd0797c5
BLAKE2b-256 checksum
How to use checksums
8c45ca8bf3202e1f741c6b2e2f651faf2ae131595260ab2d8ed65333d57398a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Release files / balrog_nle-0.9.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL balrog_nle-0.9.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.3 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
9d0fade2904ae8dc54de3ddc0c1bb0bb7425555bd0ca657c998bf378d0536062
BLAKE2b-256 checksum
How to use checksums
e530ee2aa8e5527179475087574d8da70f81dd78e4d79bc6d6d8b2f5ba404e92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Release files / balrog_nle-0.9.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL balrog_nle-0.9.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 3.2 MB
Tags CPython 3.9 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
cc808dc4d797f8319bc356c091d99dc174bccd498312f78231dd147280f11655
BLAKE2b-256 checksum
How to use checksums
47d83b92024e0327eef2e0dec3008425a6d5bc581f6f1e9760ee5054b8af79b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Release files / balrog_nle-0.9.0-cp39-cp39-macosx_11_0_arm64.whl

Download URL balrog_nle-0.9.0-cp39-cp39-macosx_11_0_arm64.whl
Size 2.8 MB
Tags CPython 3.9 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
22a595dc3ddbc651fad8c0c94e07a8c39b54adb3c9d2d2dbfaa8da099ead6fad
BLAKE2b-256 checksum
How to use checksums
90bfc423300ad3c7f4eb7c3a8742e0c5110bb8e26b7cedaa331ded5a29694eaa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Release files / balrog_nle-0.9.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL balrog_nle-0.9.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.3 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
8efbafa63047f1c6a731700c2cb5e5efdb212fc0eb64d9915732a7dcf9f68235
BLAKE2b-256 checksum
How to use checksums
ab3c14396493e91f396c6ef16fc7477fad0c9de9fcedc1dcb2350e9db3166d76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Release files / balrog_nle-0.9.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL balrog_nle-0.9.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 3.2 MB
Tags CPython 3.8 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
dd16e601f875c6c3636a9afc25799e79ac59dfebacd93c7f1c2f295b4af68d4d
BLAKE2b-256 checksum
How to use checksums
42cec40708f0f5ff7322d5727360dd09ab09cb1e0d666c3324dbdb8cbea4a0da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Release files / balrog_nle-0.9.0-cp38-cp38-macosx_10_9_x86_64.whl

Download URL balrog_nle-0.9.0-cp38-cp38-macosx_10_9_x86_64.whl
Size 3.0 MB
Tags CPython 3.8 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
24a8f72c7b43b8653eb9256746d9f799b2154153d5d752872a1e216822349d58
BLAKE2b-256 checksum
How to use checksums
d4d074761b88217db8e3cb3b20856ae195994ada973d0a55c6cc431116ee463c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Security for balrog-nle 0.9.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.9.0 This release

13 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page