Skip to main content

BALROG version of The NetHack Learning Environment (NLE)

Project description

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}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

balrog_nle-0.9.0.tar.gz (7.4 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

balrog_nle-0.9.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

balrog_nle-0.9.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

balrog_nle-0.9.0-cp311-cp311-macosx_11_0_arm64.whl (2.9 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

balrog_nle-0.9.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

balrog_nle-0.9.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

balrog_nle-0.9.0-cp310-cp310-macosx_11_0_arm64.whl (2.8 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

balrog_nle-0.9.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

balrog_nle-0.9.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.2 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

balrog_nle-0.9.0-cp39-cp39-macosx_11_0_arm64.whl (2.8 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

balrog_nle-0.9.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

balrog_nle-0.9.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.2 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ ARM64

balrog_nle-0.9.0-cp38-cp38-macosx_10_9_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

File details

Details for the file balrog_nle-0.9.0.tar.gz.

File metadata

  • Download URL: balrog_nle-0.9.0.tar.gz
  • Upload date:
  • Size: 7.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for balrog_nle-0.9.0.tar.gz
Algorithm Hash digest
SHA256 10cd24d8483353ceb58c8c817d5134bc6edd60017a0f71dc465031bfeb66b957
MD5 4f651ce9586373f012fb252d1c60efa7
BLAKE2b-256 743da1a258ec07611cd48a25955b6537d63a8afb2db1b1fa7fc436b3878c5b8d

See more details on using hashes here.

File details

Details for the file balrog_nle-0.9.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for balrog_nle-0.9.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 45ea0ef8fca88fea39f7079b1678aa7d1b73a070bee4140fcb9f3ad26906f7e2
MD5 3a556ca13a746912ca41c62045ed8e27
BLAKE2b-256 eb499bb0190fb34f290c1e4a60ef7fa64aa749bc4f53cc9c1085aa3b2511fe11

See more details on using hashes here.

File details

Details for the file balrog_nle-0.9.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for balrog_nle-0.9.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 87e2dd898af014a8f86a4dbfbf1273f7d4b525d727933a4a5e2901c9ee2393aa
MD5 48e0392e7f3390935fce298c281dbba1
BLAKE2b-256 911e09abcb7fee06476cff9f0412ac1538c16a16055714a8c587926d3e26ab3c

See more details on using hashes here.

File details

Details for the file balrog_nle-0.9.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for balrog_nle-0.9.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 18b0f36288d34f5308c4a9c0072887e9c005afdb336f60b5b6f6fa39a64313a7
MD5 3525ef287c145462f275f37ba749fb17
BLAKE2b-256 2d7d98507367213c0eec78790878559fbc703cca9489e62ec7c9f30cd9c967ba

See more details on using hashes here.

File details

Details for the file balrog_nle-0.9.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for balrog_nle-0.9.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b5a6ba1e6a7c406e7918e56f525937919bad6c8ec68df9ca2acbb6714e55dcd2
MD5 2b5263c2baa981d3b7b31ef04ebbf6de
BLAKE2b-256 90e33ea90f299b64b4896d3767ecac848304e9a96478f8164ad2cbb7da5a3323

See more details on using hashes here.

File details

Details for the file balrog_nle-0.9.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for balrog_nle-0.9.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9e31c7b014834db98425681b8af4b2cd8751bda0347338d230c60cd882c8d8e5
MD5 fcafdd5cdbbe67412f4074c55280e4db
BLAKE2b-256 faf01163b0ffef74dc050041ebc26bb44447573c397fdbccc80c646c55a7abc3

See more details on using hashes here.

File details

Details for the file balrog_nle-0.9.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for balrog_nle-0.9.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2018e8c373b7783574e90948b5a2cd6ea425653d3512c7089e21e33ffd0797c5
MD5 cd575b7165fb6fd866793c5c8489d947
BLAKE2b-256 8c45ca8bf3202e1f741c6b2e2f651faf2ae131595260ab2d8ed65333d57398a2

See more details on using hashes here.

File details

Details for the file balrog_nle-0.9.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for balrog_nle-0.9.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9d0fade2904ae8dc54de3ddc0c1bb0bb7425555bd0ca657c998bf378d0536062
MD5 a0241ea945a9dbb40bba227f94424311
BLAKE2b-256 e530ee2aa8e5527179475087574d8da70f81dd78e4d79bc6d6d8b2f5ba404e92

See more details on using hashes here.

File details

Details for the file balrog_nle-0.9.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for balrog_nle-0.9.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 cc808dc4d797f8319bc356c091d99dc174bccd498312f78231dd147280f11655
MD5 bf47f9726dfdcb556667554ff6c721bf
BLAKE2b-256 47d83b92024e0327eef2e0dec3008425a6d5bc581f6f1e9760ee5054b8af79b2

See more details on using hashes here.

File details

Details for the file balrog_nle-0.9.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for balrog_nle-0.9.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 22a595dc3ddbc651fad8c0c94e07a8c39b54adb3c9d2d2dbfaa8da099ead6fad
MD5 72292dd3354adbb0bd3d0c1cb038f826
BLAKE2b-256 90bfc423300ad3c7f4eb7c3a8742e0c5110bb8e26b7cedaa331ded5a29694eaa

See more details on using hashes here.

File details

Details for the file balrog_nle-0.9.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for balrog_nle-0.9.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8efbafa63047f1c6a731700c2cb5e5efdb212fc0eb64d9915732a7dcf9f68235
MD5 b910640260b4b2b28c472c0b0878bb4e
BLAKE2b-256 ab3c14396493e91f396c6ef16fc7477fad0c9de9fcedc1dcb2350e9db3166d76

See more details on using hashes here.

File details

Details for the file balrog_nle-0.9.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for balrog_nle-0.9.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 dd16e601f875c6c3636a9afc25799e79ac59dfebacd93c7f1c2f295b4af68d4d
MD5 ba6302a0f5864cab86b973a59c6d0efa
BLAKE2b-256 42cec40708f0f5ff7322d5727360dd09ab09cb1e0d666c3324dbdb8cbea4a0da

See more details on using hashes here.

File details

Details for the file balrog_nle-0.9.0-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for balrog_nle-0.9.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 24a8f72c7b43b8653eb9256746d9f799b2154153d5d752872a1e216822349d58
MD5 9ea11596022444d345a271cc5759bf52
BLAKE2b-256 d4d074761b88217db8e3cb3b20856ae195994ada973d0a55c6cc431116ee463c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page