The first place solution for the NeurIPS 2021 Nethack Challenge -- https://www.aicrowd.com/challenges/neurips-2021-the-nethack-challenge
The general overview of the approach can be find here (1:14:00 – 1:21:21).
For more context about the challenge and NetHack see the entire video.
Some example episode visualizations are rendered in this playlist.
We supply the repo with Dockerfile that contains all necessary dependencies to run the code.
./bin/docker-build.sh and ./bin/docker-run.sh are convinience scripts for building and running the docker container.
Note that they should be run only from the root of the repository.
./bin/docker-run.sh mounts X11 socket and Xauthority within the container to enable visualization.
You may need to tune it depending on your X11 configuration.
In Dockerfile, besides only installing dependencies,
the NLE library is pulled and slightly modified
to enable game seeding, glyph to tile mapping is generated, and tileset is downloaded,
muzero is pulled and custom patch applied (needed only for experimental reinforcement learning workflows).
We encourage using docker, but if you decide that you don’t want to use it, be sure to make sure that the environment is compatible,
e.g. NLE version supports seeding, tileset is downloaded and hardcoded path in the code changed,
autoascend/visualization/glyph2tile.py is a proper file instead of a symlink.
./bin/main.py <MODE> [PARAMS] is the main entrypoint. It has three modes:
simulate – a mode that simulates --episodes episodes, and saves results to --simulation-results json file.ray start --head beforehand).run – a mode that runs a single episode with visualization.backspace key, the agent action will be executed. delete key works similary, but fast forward 16 frames.--panic-on-error flag to handle unexpected errors gracefully.profile – a mode that profiles the code. We implemented two profilers (cProfile and pyinstrument)--profiler flag. In pyinstrument we customly process/fake tracebacks to adjustThe base strategy class with description used for defining strategies is defined in autoascend/strategy.py.
Strategy consists of entering condition and agent’s behavior. The class contains a few methods for controling the flow
and combine strategies together using functional interface (e.g. repeat, until, preempt), however strategies
can be also passed into and run inside other strategies in imperative manner if needed.
The main strategy is defined in autoascend/global_logic.py:GlobalLogic.global_strategy()
autoascend/global_logic.py – contains definitions of the main strategy and other high-level strategiesautoascend/agent.py – definition of the agent class. The agent class contains logic for updating the state of the game,autoascend/item/item.py – an item instance. Contains a list of possible glyphs, a list of possible objects,autoascend/item/inventory.py – item and inventory handling logic. That included atoms and strategies forautoascend/item/inventory_items.py – a class representing items that are in player’s inventory.autoascend/item/item_manager.py – a class for managing general information about items in the game.autoascend/combat – combat behavior and helpers.autoascend/exploration_logic.py – exploration specific strategies, including exploration within the level and across levels.autoascend/env_wrapper.py – an NLE environment wrapper. That includes utilities for forking the process and reloading the agent.autoascend/glyph – hardcoded glyphs with their meaning and related helpers.autoascend/object – hardcoded objects with their meaning and related helpers.autoascend/soko_solver – utilities and method for solving sokoban.autoascend/visualization – episode visualization tool.