GithubHelp home page GithubHelp logo

facebookresearch / minihack Goto Github PK

View Code? Open in Web Editor NEW
458.0 14.0 50.0 33.7 MB

MiniHack the Planet: A Sandbox for Open-Ended Reinforcement Learning Research

License: Apache License 2.0

Python 76.79% Shell 0.11% Jupyter Notebook 22.21% Dockerfile 0.89%

minihack's Introduction


MiniHack

MiniHack is a sandbox framework for easily designing rich and diverse environments for Reinforcement Learning (RL). Based on the game of NetHack, MiniHack uses the NetHack Learning Environment (NLE) to communicate with the game and to provide a convenient interface for customly created RL training and test environments of varying complexity. Check out our NeurIPS 2021 paper and recent blogpost.

MiniHack comes with a large list of challenging environments. However, it is primarily built for easily designing new ones. The motivation behind MiniHack is to be able to perform RL experiments in a controlled setting while being able to increasingly scale the complexity of the tasks.

To do this, MiniHack leverages the so-called description files written using a human-readable probabilistic-programming-like domain-specific language. With just a few lines of code, people can generate a large variety of Gym environments, controlling every little detail, from the location and types of monsters, to the traps, objects, and terrain of the level, all while introducing randomness that challenges generalization capabilities of RL agents. For further details, we refer users to our brief overview, detailed tutorial, or interactive notebook.

Our documentation will walk you through everything you need to know about MiniHack, step-by-step, including information on how to get started, configure environments or design new ones, train baseline agents, and much more.

MiniHack Level Editor

The MiniHack Level Editor allows to easily define MiniHack environments inside a browser using a convenient drag-and-drop functionality. The source code is available here.

Language Wrapper

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

Papers using MiniHack

Open a pull request to add papers.

Installation

The simplest way to install MiniHack is through pypi:

pip install minihack

Extending MiniHack

If you wish to extend MiniHack, please install the package as follows:

git clone https://github.com/facebookresearch/minihack
cd minihack
pip install -e ".[dev]"
pre-commit install

See the full installation guide for further information on installing and extending MiniHack on different platforms, as well as pre-installed Dockerfiles.

Submitting New Environments

For submitting your own MiniHack-based environment to our zoo of public environments, please follow the instructions here.

Trying out MiniHack

MiniHack uses the popular Gym interface for the interactions between the agent and the environment. A pre-registered MiniHack environment can be used as follows:

import gym
import minihack
env = gym.make("MiniHack-River-v0")
env.reset() # each reset generates a new environment instance
env.step(1)  # move agent '@' north
env.render()

To see the list of all MiniHack environments, run:

python -m minihack.scripts.env_list

The following scripts allow to play MiniHack environments with a keyboard:

# Play the MiniHack in the Terminal as a human
python -m minihack.scripts.play --env MiniHack-River-v0

# Use a random agent
python -m minihack.scripts.play --env MiniHack-River-v0  --mode random

# Play the MiniHack with graphical user interface (gui)
python -m minihack.scripts.play_gui --env MiniHack-River-v0

NOTE: If the package has been properly installed one could run the scripts above with mh-envs, mh-play, and mh-guiplay commands.

Baseline Agents

In order to get started with MiniHack environments, we provide a variety of baselines agent integrations.

TorchBeast

A TorchBeast agent is bundled in minihack.agent.polybeast together with a simple model to provide a starting point for experiments. To install and train this agent, first install torchbeast by following the instructions here, then use the following commands:

pip install -e ".[polybeast]"
python -m minihack.agent.polybeast.polyhydra env=MiniHack-Room-5x5-v0 total_steps=100000

More information on running our TorchBeast agents, and instructions on how to reproduce the results of the paper, can be found here. The learning curves for all of our polybeast experiments can be accessed in our Weights&Biases repository.

RLlib

An RLlib agent is provided in minihack.agent.rllib, with a similar model to the torchbeast agent. This can be used to try out a variety of different RL algorithms. To install and train an RLlib agent, use the following commands:

pip install -e ".[rllib]"
python -m minihack.agent.rllib.train algo=dqn env=MiniHack-Room-5x5-v0 total_steps=1000000

More information on running RLlib agents can be found here.

Unsupervised Environment Design

MiniHack also enables research in Unsupervised Environment Design, whereby an adaptive task distribution is learned during training by dynamically adjusting free parameters of the task MDP. Check out the ucl-dark/paired repository for replicating the examples from the paper using the PAIRED.

Citation

If you use MiniHack in your work, please cite:

@inproceedings{samvelyan2021minihack,
  title={MiniHack the Planet: A Sandbox for Open-Ended Reinforcement Learning Research},
  author={Mikayel Samvelyan and Robert Kirk and Vitaly Kurin and Jack Parker-Holder and Minqi Jiang and Eric Hambro and Fabio Petroni and Heinrich Kuttler and Edward Grefenstette and Tim Rockt{\"a}schel},
  booktitle={Thirty-fifth Conference on Neural Information Processing Systems Datasets and Benchmarks Track (Round 1)},
  year={2021},
  url={https://openreview.net/forum?id=skFwlyefkWJ}
}

If you use our example ported environments, please cite the original papers: MiniGrid (see license, bib), Boxoban (see license, bib).

Contributions and Maintenance

MiniHack was built and is maintained by Meta AI (FAIR), UCL DARK and University of Oxford. We welcome contributions to MiniHack. If you are interested in contributing, please see this document. Our maintenance plan can be found here.

minihack's People

Contributors

bam4d avatar bartekcupial avatar boxofcereal avatar garymm avatar geremiapompei avatar ian-cannon avatar mohamadmansourx avatar ouked avatar rockt avatar samvelyan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

minihack's Issues

Cannot run MiniHack with gui

🐛 Bug

After setting up the environment, I tried to run this command:
python -m minihack.scripts.play_gui --env MiniHack-River-v0
However nothing is displayed (the scripts exits), and some warning are displayed.

To Reproduce

Steps to reproduce the behavior:

  1. Setup environment as described in Readme file
  2. Run scripts here
  3. The last command doesn't function properly.

Warning displayed in terminal window:

/home/ayoub/Desktop/Projects/rl/minihack/minihack/minihack/tiles/window.py:32: MatplotlibDeprecationWarning:
The set_window_title function was deprecated in Matplotlib 3.4 and will be removed two minor releases later. Use manager.set_window_title or GUI-specific methods instead.
self.fig.canvas.set_window_title(title)
/home/ayoub/Desktop/Projects/rl/minihack/minihack/minihack/tiles/window.py:72: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
plt.pause(0.001)
/home/ayoub/Desktop/Projects/rl/minihack/minihack/minihack/tiles/window.py:101: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
plt.show()

Expected behavior

Scripting launching a gui window.

Environment

Collecting environment information...
MiniHack version: 0.1.1+041bfc7
NLE version: 0.7.3
PyTorch version: N/A
Is debug build: N/A
CUDA used to build PyTorch: N/A

OS: Ubuntu 20.04.3 LTS
GCC version: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
CMake version: version 3.17.2

Python version: 3.9
Is CUDA available: N/A
CUDA runtime version: 10.1.243
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: Could not collect

Versions of relevant libraries:
[pip3] numpy==1.21.3
[conda] Could not collect

Additional context

None

[BUG] It looks like there some references to the legacy _actions property

🐛 Bug

Reward Manager expects environment to have _actions rather than actions.

To Reproduce

Steps to reproduce the behavior:

  1. python -m minihack.scripts.play --env MiniHack-Pray-v0
  2. Take 1 action

Additional context

This property changed named from nle 0.8.1 to 0.9.0. I think we just need probably just need to update the references to actions everywhere? It seems to be in few places still search results

[FEATURE] Gymnasium support

🚀 Feature

Upgrading from the (by now pretty old) gym version to gymnasium.

Motivation

Better usability of MiniHack with standard training libraries like SB3.

Pitch

Since gymnasium is becoming the default in more and more training libraries, it would be great to be able to use MiniHack in gymnasium.

Alternatives

Additional context

I don't know exactly how much effort that would mean in MiniHack, but I upgraded a package from gym to gymnasium with relatively small effort (for me it was mostly just changing the import, making sure the signature is updated and that the registration still does what it should). So hopefully this could be done fairly quickly.

[BUG] FileNotFoundError: [Errno 2] No such file or directory: '/tmp/nlew7mo9hzl'

🐛 Bug

We get a file not found error when looking for the NetHack temporary directory after running our RL algorithm for > 1M steps. This error doesn't occur on all runs, only some runs get this error. We use the following environment wrapper over MiniHack:
https://github.com/AGI-Labs/continual_rl/blob/develop/continual_rl/experiments/tasks/make_minihack_task.py.

To Reproduce

Steps to reproduce the behavior:

We run our RL algorithm on any Minihack environments (RoomRandom-15x15 or RoomTrap-15x15). Occasionally after around 1M steps we obtain the following FileNotFoundError when looking for the NetHack tmp directory:

Screen Shot 2023-06-04 at 11 14 29 PM

Expected behavior

No FileNotFoundError when running our RL algorithm on MiniHack.

Environment

I'm running this on a SLURM scheduler so didn't collect the GPU info.

Collecting environment information...
MiniHack version: 0.1.3
NLE version: 0.8.1
Gym version: 0.23.1
PyTorch version: N/A
Is debug build: N/A
CUDA used to build PyTorch: N/A

OS: CentOS Linux release 8.1.1911 (Core)
GCC version: (conda-forge gcc 10.3.0-16) 10.3.0
CMake version: version 3.23.2

Python version: 3.8
Is CUDA available: N/A
CUDA runtime version: Could not collect
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: Could not collect

Versions of relevant libraries:
[pip3] numpy==1.19.5
[conda] Could not collect

Additional context

[BUG] Minihack does not work with NLE v0.9.0

🐛 Bug

Minihack does not work with NLE v0.9.0

To Reproduce

Follow the Trying Out MiniHack example

[/usr/local/lib/python3.7/dist-packages/minihack/base.py](https://localhost:8080/#) in _patch_nhdat(self, des_file)
    366         """
    367         if not des_file.endswith(".des"):
--> 368             fpath = os.path.join(self.env._vardir, "mylevel.des")
    369             # If the des-file is passed as a string
    370             with open(fpath, "w") as f:

AttributeError: 'MiniHackRiver' object has no attribute 'env'

[BUG]

🐛 Bug

Boxoban data is being downloaded in the wrong folder.

To Reproduce

Steps to reproduce the behavior:

  1. Run minihack/scripts/download_boxoban_levels.py
    2.Try to run any boxoban environment

Additional context

The reason probably is that Boxoban env is looking for data in the wrong folder:

LEVELS_PATH = os.path.join(
pkg_resources.resource_filename("nle", "minihack/dat"),
"boxoban-levels-master",

For some reason it expects the data to be in nle package, while it's being downloaded to the minihack package folder.

[FEATURE] monobeast baseline implementation

🚀 Feature

current polybeast implementation has most code written in C++, requesting for mnonobeast implementation for more clarity

Motivation

readability/flexibility

Pitch

monobeast implementation will offfer more readability and flexibility

Alternatives

N/A

Additional context

N/A

[FEATURE] Simpler user experience when placing items

🚀 Feature

A complete catalog of items that you can sample from, sorted by their type (e.g. weapon, edible...). This might be done by adapting the data from this issue.

Motivation

We can already find the meaning of all the commands and all placeable tiles, and a subset of edible items are also listed in the rewards manager file. But we don't yet have a catalog of all placeable items/edibles.

Pitch

This feature will make generation of map much easier and more complete. e.g, we might want to generate levels with different weapons and train agents to behave differently accordingly, or train them to behave identically regardless of what weapon is on the ground.

Alternatives

Additional context

I'm new to the package and I'm happy to learn more about it. I looked and didn't find a similar feature. If there has already been ways of implementing this, can you shed some light on how to do this? Thank you.

[BUG] flake8 rejecting commits due to existing code

Despite making no changes to the base.py file, flake8 is failing on that file and not allowing me to commit changes to another file.

flake8...................................................................Failed                                                                                                                
- hook id: flake8                                                                                                                                                                              
- exit code: 1                                                                                                                                                                                 
                                                                                                                                                                                               
minihack/base.py:364:25: B907 'key' is manually surrounded by quotes, consider using the `!r` conversion flag.                                                                                 
                        f'Observation key "{key}" is not supported'                                                                                                                            
                        ^                                                                                                                                                                      
minihack/base.py:451:13: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling.  See https
://docs.python.org/3/tutorial/errors.html#exception-chaining for details.                                                                                                                      
            raise RuntimeError(f"Couldn't patch the nhdat file.\n{e}")                                                                                                                         
            ^                                                                                                                                                                                  
minihack/base.py:523:29: B905 `zip()` without an explicit `strict=` parameter.                                                                                                                 
        for letter, line in zip(inv_letters, inv_strs):                                                                                                                                        
                            ^                                                                                                                                                                  
                                                                                                                                                                                               
[WARNING] Stashed changes conflicted with hook auto-fixes... Rolling back fixes... 

Despite trying to add those error codes to the .flake8 ignore, they are still not being ignored. Not sure how that all works to be honest.

[BUG]

🐛 Bug

I’m Scientist (physicist a bit too) and Analyst but in Finland they started killing me using Leponex and other toxics and say I’m mentally ill. + remote control of brain since 2013 (partial)

We have talked about porting minihack to Windows earlier.

To Reproduce

Steps to reproduce the behavior:

  1. Go Finland

Expected behavior

Do you want to help me? We could do useful co-operation?

Environment

Please copy and paste the output from running our
environment collection script
(or fill out the checklist below manually).

You can get the script and run it with:

# with repo already installed
$ python -m minihack.scripts.collect_env

# or instead pull it from github
wget https://raw.githubusercontent.com/facebookresearch/minihack/main/minihack/scripts/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py
  • MiniHack Version (e.g., 1.0):
  • NLE Version (e.g. 1.0)
  • PyTorch Version (e.g., 1.0):
  • OS (e.g., Linux):
  • How you installed MiniHack (conda, pip, source):
  • Build command you used (if compiling from source):
  • Python version:
  • CUDA/cuDNN version:
  • GPU models and configuration:
  • Any other relevant information:

Additional context

I have born in 1980 and Finland killed me for no good reason.

Contact me: [email protected]

[BUG] RLlib Basline doesn't work with docker image

🐛 Bug

Using the bionic docker image, attempting to install and run the rllib agents results in errors.

To Reproduce

Steps to reproduce the behavior:

  1. download docker image + run
  2. pip install minihack[rllib]
  3. python -m minihack.agent.rllib.train algo=dqn env=MiniHack-Room-5x5-v0 total_steps=1000000

I then get the following error:

First set of errors /opt/conda/lib/python3.8/site-packages/ale_py/roms/__init__.py:94: DeprecationWarning: Automatic importing of atari-py roms won't be supported in future releases of ale-py. Please migrate over to using `ale-import-roms` OR an ALE-supported ROM package. To make this warning disappear you can run `ale-import-roms --import-from-pkg atari_py.atari_roms`.For more information see: https://github.com/mgbellemare/Arcade-Learning-Environment#rom-management _RESOLVED_ROMS = _resolve_roms() Traceback (most recent call last): File "/opt/conda/lib/python3.8/runpy.py", line 185, in _run_module_as_main mod_name, mod_spec, code = _get_module_details(mod_name, _Error) File "/opt/conda/lib/python3.8/runpy.py", line 111, in _get_module_details __import__(pkg_name) File "/opt/conda/lib/python3.8/site-packages/minihack/agent/rllib/__init__.py", line 3, in from .train import train File "/opt/conda/lib/python3.8/site-packages/minihack/agent/rllib/train.py", line 8, in import minihack.agent.rllib.models # noqa: F401 File "/opt/conda/lib/python3.8/site-packages/minihack/agent/rllib/models.py", line 24, in from ray.rllib.models import ModelCatalog File "/opt/conda/lib/python3.8/site-packages/ray/rllib/__init__.py", line 5, in from ray.rllib.env.base_env import BaseEnv File "/opt/conda/lib/python3.8/site-packages/ray/rllib/env/__init__.py", line 6, in from ray.rllib.env.policy_client import PolicyClient File "/opt/conda/lib/python3.8/site-packages/ray/rllib/env/policy_client.py", line 14, in from ray.rllib.policy.sample_batch import MultiAgentBatch File "/opt/conda/lib/python3.8/site-packages/ray/rllib/policy/__init__.py", line 1, in from ray.rllib.policy.policy import Policy File "/opt/conda/lib/python3.8/site-packages/ray/rllib/policy/policy.py", line 9, in from ray.rllib.models.catalog import ModelCatalog File "/opt/conda/lib/python3.8/site-packages/ray/rllib/models/__init__.py", line 1, in from ray.rllib.models.action_dist import ActionDistribution File "/opt/conda/lib/python3.8/site-packages/ray/rllib/models/action_dist.py", line 4, in from ray.rllib.models.modelv2 import ModelV2 File "/opt/conda/lib/python3.8/site-packages/ray/rllib/models/modelv2.py", line 7, in from ray.rllib.models.preprocessors import get_preprocessor, \ File "/opt/conda/lib/python3.8/site-packages/ray/rllib/models/preprocessors.py", line 2, in import cv2 File "/opt/conda/lib/python3.8/site-packages/cv2/__init__.py", line 9, in from .cv2 import _registerMatType ImportError: cannot import name '_registerMatType' from 'cv2.cv2' (/opt/conda/lib/python3.8/site-packages/cv2/cv2.cpython-38-x86_64-linux-gnu.so)

This appears to be an error with with opencv-python-headless. Alongside this I found that doing the following was needed:

pip install aiohttp==3.7.4
pip install async-timeout 3.0.1
pip install aioredis==1.3.1
pip install gym==0.15.3

And then you get the following error:

Second set of errors /opt/conda/lib/python3.8/runpy.py:127: RuntimeWarning: 'minihack.agent.rllib.train' found in sys.modules after import of package 'minihack.agent.rllib', but prior to execution of 'minihack.agent.rllib.train'; this may result in unpredictable behaviour warn(RuntimeWarning(msg)) 2022-04-11 20:10:50,714 INFO services.py:1267 -- View the Ray dashboard at http://127.0.0.1:8265 2022-04-11 20:10:50,720 WARNING services.py:1716 -- WARNING: The object store is using /tmp instead of /dev/shm because /dev/shm has only 67108864 bytes available. This will harm performance! You may be able to free up space by deleting files in /dev/shm. If you are inside a Docker container, you can increase /dev/shm size by passing '--shm-size=10.12gb' to 'docker run' (or add it to the run_options list in a Ray cluster config). Make sure to set this to more than 30% of available RAM. 2022-04-11 20:10:52,380 ERROR syncer.py:72 -- Log sync requires rsync to be installed. == Status == Memory usage on this node: 3.1/31.2 GiB Using FIFO scheduling algorithm. Resources requested: 9.0/9 CPUs, 0/0 GPUs, 0.0/18.39 GiB heap, 0.0/9.2 GiB objects Result logdir: /root/ray_results/DQN_2022-04-11_20-10-52 Number of trials: 1/1 (1 RUNNING) +-----------------------------+----------+-------+ | Trial name | status | loc | |-----------------------------+----------+-------| | DQN_RLlibNLE-v0_7ca8a_00000 | RUNNING | | +-----------------------------+----------+-------+

2022-04-11 20:10:52,835 WARNING worker.py:1115 -- The agent on node 5de9f6604cc5 failed with the following error:
Traceback (most recent call last):
File "/opt/conda/lib/python3.8/site-packages/ray/new_dashboard/agent.py", line 326, in
loop.run_until_complete(agent.run())
File "/opt/conda/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/opt/conda/lib/python3.8/site-packages/ray/new_dashboard/agent.py", line 138, in run
modules = self._load_modules()
File "/opt/conda/lib/python3.8/site-packages/ray/new_dashboard/agent.py", line 92, in _load_modules
c = cls(self)
File "/opt/conda/lib/python3.8/site-packages/ray/new_dashboard/modules/reporter/reporter_agent.py", line 148, in init
self._metrics_agent = MetricsAgent(dashboard_agent.metrics_export_port)
File "/opt/conda/lib/python3.8/site-packages/ray/_private/metrics_agent.py", line 74, in init
prometheus_exporter.new_stats_exporter(
File "/opt/conda/lib/python3.8/site-packages/ray/_private/prometheus_exporter.py", line 333, in new_stats_exporter
exporter = PrometheusStatsExporter(
File "/opt/conda/lib/python3.8/site-packages/ray/_private/prometheus_exporter.py", line 266, in init
self.serve_http()
File "/opt/conda/lib/python3.8/site-packages/ray/_private/prometheus_exporter.py", line 320, in serve_http
start_http_server(
File "/opt/conda/lib/python3.8/site-packages/prometheus_client/exposition.py", line 168, in start_wsgi_server
TmpServer.address_family, addr = _get_best_family(addr, port)
File "/opt/conda/lib/python3.8/site-packages/prometheus_client/exposition.py", line 157, in _get_best_family
infos = socket.getaddrinfo(address, port)
File "/opt/conda/lib/python3.8/socket.py", line 918, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

(raylet) Traceback (most recent call last):
(raylet) File "/opt/conda/lib/python3.8/site-packages/ray/new_dashboard/agent.py", line 338, in
(raylet) raise e
(raylet) File "/opt/conda/lib/python3.8/site-packages/ray/new_dashboard/agent.py", line 326, in
(raylet) loop.run_until_complete(agent.run())
(raylet) File "/opt/conda/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
(raylet) return future.result()
(raylet) File "/opt/conda/lib/python3.8/site-packages/ray/new_dashboard/agent.py", line 138, in run
(raylet) modules = self._load_modules()
(raylet) File "/opt/conda/lib/python3.8/site-packages/ray/new_dashboard/agent.py", line 92, in _load_modules
(raylet) c = cls(self)
(raylet) File "/opt/conda/lib/python3.8/site-packages/ray/new_dashboard/modules/reporter/reporter_agent.py", line 148, in init
(raylet) self._metrics_agent = MetricsAgent(dashboard_agent.metrics_export_port)
(raylet) File "/opt/conda/lib/python3.8/site-packages/ray/_private/metrics_agent.py", line 74, in init
(raylet) prometheus_exporter.new_stats_exporter(
(raylet) File "/opt/conda/lib/python3.8/site-packages/ray/_private/prometheus_exporter.py", line 333, in new_stats_exporter
(raylet) exporter = PrometheusStatsExporter(
(raylet) File "/opt/conda/lib/python3.8/site-packages/ray/_private/prometheus_exporter.py", line 266, in init
(raylet) self.serve_http()
(raylet) File "/opt/conda/lib/python3.8/site-packages/ray/_private/prometheus_exporter.py", line 320, in serve_http
(raylet) start_http_server(
(raylet) File "/opt/conda/lib/python3.8/site-packages/prometheus_client/exposition.py", line 168, in start_wsgi_server
(raylet) TmpServer.address_family, addr = _get_best_family(addr, port)
(raylet) File "/opt/conda/lib/python3.8/site-packages/prometheus_client/exposition.py", line 157, in _get_best_family
(raylet) infos = socket.getaddrinfo(address, port)
(raylet) File "/opt/conda/lib/python3.8/socket.py", line 918, in getaddrinfo
(raylet) for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
(raylet) socket.gaierror: [Errno -2] Name or service not known
(pid=1119) 2022-04-11 20:10:53,571 INFO trainer.py:694 -- Current log_level is WARN. For more information, set 'log_level': 'INFO' / 'DEBUG' or use the -v and -vv flags.
2022-04-11 20:10:54,630 WARNING worker.py:1115 -- The agent on node 5de9f6604cc5 failed with the following error:
Traceback (most recent call last):
File "/opt/conda/lib/python3.8/site-packages/ray/new_dashboard/agent.py", line 326, in
loop.run_until_complete(agent.run())
File "/opt/conda/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/opt/conda/lib/python3.8/site-packages/ray/new_dashboard/agent.py", line 138, in run
modules = self._load_modules()
File "/opt/conda/lib/python3.8/site-packages/ray/new_dashboard/agent.py", line 92, in _load_modules
c = cls(self)
File "/opt/conda/lib/python3.8/site-packages/ray/new_dashboard/modules/reporter/reporter_agent.py", line 148, in init
self._metrics_agent = MetricsAgent(dashboard_agent.metrics_export_port)
File "/opt/conda/lib/python3.8/site-packages/ray/_private/metrics_agent.py", line 74, in init
prometheus_exporter.new_stats_exporter(
File "/opt/conda/lib/python3.8/site-packages/ray/_private/prometheus_exporter.py", line 333, in new_stats_exporter
exporter = PrometheusStatsExporter(
File "/opt/conda/lib/python3.8/site-packages/ray/_private/prometheus_exporter.py", line 266, in init
self.serve_http()
File "/opt/conda/lib/python3.8/site-packages/ray/_private/prometheus_exporter.py", line 320, in serve_http
start_http_server(
File "/opt/conda/lib/python3.8/site-packages/prometheus_client/exposition.py", line 168, in start_wsgi_server
TmpServer.address_family, addr = _get_best_family(addr, port)
File "/opt/conda/lib/python3.8/site-packages/prometheus_client/exposition.py", line 157, in _get_best_family
infos = socket.getaddrinfo(address, port)
File "/opt/conda/lib/python3.8/socket.py", line 918, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

(raylet) Traceback (most recent call last):
(raylet) File "/opt/conda/lib/python3.8/site-packages/ray/new_dashboard/agent.py", line 338, in
(raylet) raise e
(raylet) File "/opt/conda/lib/python3.8/site-packages/ray/new_dashboard/agent.py", line 326, in
(raylet) loop.run_until_complete(agent.run())
(raylet) File "/opt/conda/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
(raylet) return future.result()
(raylet) File "/opt/conda/lib/python3.8/site-packages/ray/new_dashboard/agent.py", line 138, in run
(raylet) modules = self._load_modules()
(raylet) File "/opt/conda/lib/python3.8/site-packages/ray/new_dashboard/agent.py", line 92, in _load_modules
(raylet) c = cls(self)
(raylet) File "/opt/conda/lib/python3.8/site-packages/ray/new_dashboard/modules/reporter/reporter_agent.py", line 148, in init
(raylet) self._metrics_agent = MetricsAgent(dashboard_agent.metrics_export_port)
(raylet) File "/opt/conda/lib/python3.8/site-packages/ray/_private/metrics_agent.py", line 74, in init
(raylet) prometheus_exporter.new_stats_exporter(
(raylet) File "/opt/conda/lib/python3.8/site-packages/ray/_private/prometheus_exporter.py", line 333, in new_stats_exporter
(raylet) exporter = PrometheusStatsExporter(
(raylet) File "/opt/conda/lib/python3.8/site-packages/ray/_private/prometheus_exporter.py", line 266, in init
(raylet) self.serve_http()
(raylet) File "/opt/conda/lib/python3.8/site-packages/ray/_private/prometheus_exporter.py", line 320, in serve_http
(raylet) start_http_server(
(raylet) File "/opt/conda/lib/python3.8/site-packages/prometheus_client/exposition.py", line 168, in start_wsgi_server
(raylet) TmpServer.address_family, addr = _get_best_family(addr, port)
(raylet) File "/opt/conda/lib/python3.8/site-packages/prometheus_client/exposition.py", line 157, in _get_best_family
(raylet) infos = socket.getaddrinfo(address, port)
(raylet) File "/opt/conda/lib/python3.8/socket.py", line 918, in getaddrinfo
(raylet) for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
(raylet) socket.gaierror: [Errno -2] Name or service not known

With the socket.gaierror repeating. Thanks for the help!

About full-observed MDP

Hi,
I feel this is nice work and it is convenient to configure an environment via des-file. However, I find that the observations in all tasks are partially-observed (i.e. some information is hidden from the agent's view).

Does there exist some interface to make the observations fully observed?

Menus not resolving properly

🐛 Bug

Note, I am unsure if this is an issue with NLE, Minihack, or NetHack itself.
I am reporting it here since I've only managed to reproduce this issue with MiniHack so far:
It seems like sometimes menus that ask for key-presses aren't properly resolved.
For example drinking from a fountain will ask "Drink from the fountain? [yn] (n)".
Pressing "y" should resolve it for example with "The cool draught refreshes you".
However, sometimes the same message "Drink from the fountain? [yn] (n)" just appears again.
The odd thing is that I've checked the internal flags if there is a menu open, and they are set to false.
Note that I've seen this happen with other instances like kicking open a door, or being asked if I want to attack a friendly monster.

I am working on an agent that plays NetHack using Large Language Models.
As such, these messages confuse my agent.

To Reproduce

  1. Run the code below to reproduce my example from above. Note the odd seeding is just a result of my code.
  2. In the for loop replace "error_action_sequence" with "working_action_sequence" to get the expected behaviour.
  3. Using the error_action_sequence the last two outputs will be
    Drink from the fountain? [yn] (n) True False False
    Drink from the fountain? [yn] (n) y False False False
  4. Using the working_action_sequence the last two outputs are correct.
    Drink from the fountain? [yn] (n) True False False
    The cool draught refreshes you. False False False

Note how in both cases all menu-flags are false at the end.
I also noticed that in the "error" case there is an additional "y" in the message as if I am typing.
However, I am unable to reproduce such a behaviour on alt.org/nethack.
Additionally, I am unable to confirm the message, since any additional input will be treated as if there is no menu.

import sys
from minihack.base import MiniHack
from gymnasium.utils import seeding
from nle.env.base import nethack

des_file = """
MAZE: "mylevel", ' '
FLAGS:hardfloor
INIT_MAP: solidfill,' '
GEOMETRY:center,center
MAP
--------     --------
|......|     |......|
|......|#####|......|
|......|     |......|
--------     --------
    #
    #
--------
|......|
|......|
|......|
--------
ENDMAP
REGION:(1,1,6,3),lit,"ordinary"
REGION:(14,1,19,3),lit,"ordinary"
REGION:(1,8,6,11),lit,"ordinary"

DOOR:closed,(4,4)
DOOR:closed,(7,2)
DOOR:closed,(4,7)
DOOR:closed,(13,2)

$all_rooms = selection: fillrect(1,1,6,3) & fillrect(1,8,6,10) & fillrect(14,1,19,3)
OBJECT: "full healing", rndcoord($all_rooms)
FOUNTAIN: rndcoord($all_rooms)
"""

_np_random, seed = seeding.np_random(474862)
env = MiniHack(
    des_file=des_file,
    character="@",
    actions=nethack.ACTIONS
)

seed = 474862
env.seed(core=seed, disp=seed)
obs = env.reset()
seed = _np_random.integers(sys.maxsize)
env.seed(core=seed, disp=seed)
obs = env.reset()

working_action_sequence = [3, 7, 0, 0, 0, 0, 0, 0, 0, 3, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 64, 7]
error_action_sequence = [3, 7, 0, 0, 0, 0, 0, 0, 0, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 64, 7]

for i, action in enumerate(error_action_sequence):
    obs, reward, done, info = env.step(action)
    waiting_for_yn = bool(env.last_observation[env._internal_index][1])
    waiting_for_line = bool(env.last_observation[env._internal_index][2])
    waiting_for_space = bool(env.last_observation[env._internal_index][3])
    print("".join([chr(c) for c in obs["message"] if c != 0]), waiting_for_yn, waiting_for_line, waiting_for_space)

Environment

Collecting environment information...
/opt/conda/lib/python3.8/site-packages/torch/cuda/init.py:52: UserWarning: CUDA initialization: Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from http://www.nvidia.com/Download/index.aspx (Triggered internally at ../c10/cuda/CUDAFunctions.cpp:100.)
return torch._C._cuda_getDeviceCount() > 0
MiniHack version: 0.1.5
NLE version: 0.9.0
Gym version: 0.26.2
PyTorch version: 1.8.0a0+1606899
Is debug build: No
CUDA used to build PyTorch: 11.1

OS: Ubuntu 20.04.1 LTS
GCC version: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
CMake version: version 3.18.2

Python version: 3.8
Is CUDA available: No
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA

Versions of relevant libraries:
[pip3] numpy==1.24.4
[pip3] pytorch-transformers==1.1.0
[pip3] torch==1.8.0a0+1606899
[pip3] torchtext==0.9.0a0
[pip3] torchvision==0.9.0a0
[conda] magma-cuda110 2.5.2 5 local
[conda] mkl 2019.4 243
[conda] mkl-include 2019.4 243
[conda] nomkl 3.0 0
[conda] pytorch-transformers 1.1.0 pypi_0 pypi
[conda] torch 1.8.0a0+1606899 pypi_0 pypi
[conda] torchtext 0.9.0a0 pypi_0 pypi
[conda] torchvision 0.9.0a0 pypi_0 pypi

[BUG] `reward_lose` not correctly set at timeout

🐛 Bug

When setting max_episode_steps, while gym correctly triggers a reset, MiniHack (and perhaps even NLE) does not set StepStatus.ABORTED.

As a consequence, the reward for Timeout is not reward_lose.

To Reproduce

import gym
import gym.vector
import minihack

MAX_STEPS = 20

env = gym.make(
    "MiniHack-KeyRoom-S5-v0",
    reward_lose=-1.0,
    max_episode_steps=MAX_STEPS,
)
timestep = env.reset()
env.render()


for i in range(MAX_STEPS):
    timestep = env.step(3) 
    reward = timestep[1]
    info = timestep[-1]
    print(reward, info["end_status"])

assert int(info["end_status"]) == -1

Expected behavior

int(info["end_status"]) should be -1

Potential reasons

gym.make accepts max_episode_steps as argument.
For this reason, max_episode_steps is not included in kwargs and it is not passed through to the MiniHack constructor.

[BUG] Broken monster generation from des file

🐛 Bug

I'm trying to generate different levels using des files. It works fine when I'm using just map. But MONSTER brakes env: instead of my map it returns some different random levels

To Reproduce

Steps to reproduce the behavior:

  1. Generate env with MONSTER
  2. Try to render it with get_des_file_rendering

this generates random levels:

from minihack.tiles.rendering import get_des_file_rendering
import IPython.display
def render_des_file(des_file, **kwargs):
    image = get_des_file_rendering(des_file, **kwargs)
    IPython.display.display(image)

des = """
MAZE: "mylevel", ' '
FLAGS:premapped
GEOMETRY:center,center

MAP
.....
.....
L....
..L..
|....
ENDMAP

STAIR:(4, 4),down
BRANCH: (0,0,0,0),(1,1,1,1)
MONSTER:'v',"dust vortex",(0,4)
"""
render_des_file(des, n_images=2, full_screen=False)

this works ok:

des = """
MAZE: "mylevel", ' '
FLAGS:premapped
GEOMETRY:center,center

MAP
.....
.....
L....
..L..
|....
ENDMAP

STAIR:(4, 4),down
BRANCH: (0,0,0,0),(1,1,1,1)
"""
render_des_file(des, n_images=2, full_screen=False)

Expected behavior

Env consists of map described is des file

Environment

Collecting environment information...
MiniHack version: 0.1.3
NLE version: 0.8.1
Gym version: 0.21.0
PyTorch version: 1.12.0+cu113
Is debug build: No
CUDA used to build PyTorch: 11.3

OS: Ubuntu 18.04.5 LTS
GCC version: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
CMake version: version 3.22.5

Python version: 3.7
Is CUDA available: Yes
CUDA runtime version: Could not collect
GPU models and configuration: GPU 0: Tesla T4
Nvidia driver version: 460.32.03
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.7.6.5
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.0.5

Versions of relevant libraries:
[pip3] numpy==1.21.6
[pip3] torch==1.12.0+cu113
[pip3] torchaudio==0.12.0+cu113
[pip3] torchsummary==1.5.1
[pip3] torchtext==0.13.0
[pip3] torchvision==0.13.0+cu113
[conda] Could not collect

[BUG] Can't decode reward (manager)

🐛 Bug

File "/blah.py", line 61, in step
ob, rew, done, info = self.env.step(action)
File "/home/me/miniconda3/envs/minihack/lib/python3.7/site-packages/minihack/base.py", line 357, in step
return super().step(action)
File "/home/me/miniconda3/envs/minihack/lib/python3.7/site-packages/nle/env/base.py", line 373, in step
end_status = self._is_episode_end(observation)
File "/home/me/miniconda3/envs/minihack/lib/python3.7/site-packages/minihack/base.py", line 364, in _is_episode_end
self, self._previous_obs, self._previous_action, observation
File "/home/me/miniconda3/envs/minihack/lib/python3.7/site-packages/minihack/reward_manager.py", line 732, in check_episode_end_call
env, previous_observation, action, observation
File "/home/me/miniconda3/envs/minihack/lib/python3.7/site-packages/minihack/reward_manager.py", line 241, in check
.decode("utf-8")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x9c in position 0: invalid start byte

Environment

MiniHack version: 0.1.4
NLE version: 0.9.0
Gym version: 0.23.0
PyTorch version: 1.13.1
Is debug build: No
CUDA used to build PyTorch: 11.6

OS: Ubuntu 20.04.5 LTS
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
CMake version: version 3.16.3

Python version: 3.7
Is CUDA available: Yes
CUDA runtime version: Could not collect
GPU models and configuration: GPU 0: Quadro K620
Nvidia driver version: 515.86.01
cuDNN version: Could not collect

Versions of relevant libraries:
[pip3] numpy==1.21.6
[pip3] torch==1.13.1
[pip3] torchaudio==0.13.1
[pip3] torchvision==0.13.1a0
[conda] blas 1.0 mkl
[conda] mkl 2021.4.0 h06a4308_640
[conda] mkl-service 2.4.0 py37h7f8727e_0
[conda] mkl_fft 1.3.1 py37hd3c417c_0
[conda] mkl_random 1.2.2 py37h51133e4_0
[conda] pytorch 1.13.1 py3.7_cuda11.6_cudnn8.3.2_0 pytorch
[conda] pytorch-cuda 11.6 h867d48c_1 pytorch
[conda] pytorch-mutex 1.0 cuda pytorch
[conda] torchaudio 0.13.1 py37_cu116 pytorch
[conda] torchvision 0.13.1 cpu_py37h164cc8f_0

Additional context

I'm getting segmentation faults from running the C nle Nethack.reset() function, and this is one bug I've had between those segmentation faults. Perhaps they are related.

[BUG] Additional software required on Linux

🐛 Bug

I had to install additional software before nle would build on Linux
Some requirements were obvious to me, some were not.

Here's what worked

conda create -n minihack python=3.8
conda activate minihack
sudo apt install cmake
sudo apt install build-essential
sudo apt install python3-dev
sudo apt install libbz2-dev
pip install minihack
# NB> I had previously run sudo apt install libpcre3-dev
# in order to install gym

To Reproduce

run (without the additional dependencies)

conda create -n minihack python=3.8
conda activate minihack
pip install minihack

result;

Failed to build nle
ERROR: Could not build wheels for nle which use PEP 517 and cannot be installed directly

Environment

Linux Mint 20.2
Python 3.8.12
conda 4.10.3

[FEATURE] Update Corridor, ExploreMaze, BoxoHack to allow different actions

🚀 Feature

Corridor, ExploreMaze, and BoxoHack each only allow for hard-coded actions. This change would allow users to define what actions they would allow in the environment.

Motivation

Transfer learning on these environments would be difficult if the action space is forced to change while it is allowed in other environments. This change would use the same method as other environments to allow new actions but still give defaults should the key not appear in kwargs

Pitch

Single line changes to each of the environments. I do not think these are large enough to warrant testing or API changes.

Help: running the "get_des_file_rendering"

Hi, I tried running this by following the guide:
`
from minihack.tiles.rendering import get_des_file_rendering
import IPython.display

def render_des_file(des_file, **kwargs):
image = get_des_file_rendering(des_file, **kwargs)
IPython.display.display(image)

des_file = """
MAZE: "mylevel", ' '
FLAGS:premapped
GEOMETRY:center,center
MAP
.....
.....
.....
.....
.....
ENDMAP
"""
render_des_file(des_file, n_images=1, full_screen=False)
`

got the following problem:
Traceback (most recent call last): File "/Users/saharadmoni/Programming/PycharmProjects/Minihack/main.py", line 29, in <module> render_des_file(des_file, n_images=1, full_screen=False) File "/Users/saharadmoni/Programming/PycharmProjects/Minihack/main.py", line 13, in render_des_file image = get_des_file_rendering(des_file, **kwargs) File "/Users/saharadmoni/anaconda3/envs/minihack/lib/python3.8/site-packages/minihack/tiles/rendering.py", line 65, in get_des_file_rendering env = MHCustom( File "/Users/saharadmoni/anaconda3/envs/minihack/lib/python3.8/site-packages/minihack/tiles/rendering.py", line 43, in __init__ super().__init__(*args, des_file=des_file, **kwargs) File "/Users/saharadmoni/anaconda3/envs/minihack/lib/python3.8/site-packages/minihack/skills.py", line 52, in __init__ super().__init__(*args, des_file=des_file, **kwargs) File "/Users/saharadmoni/anaconda3/envs/minihack/lib/python3.8/site-packages/minihack/base.py", line 271, in __init__ super().__init__(*args, **kwargs) File "/Users/saharadmoni/anaconda3/envs/minihack/lib/python3.8/site-packages/nle/env/tasks.py", line 53, in __init__ super().__init__(*args, actions=actions, **kwargs) TypeError: __init__() got an unexpected keyword argument 'archivefile'

Ran on Mac silicone conda environment python 3.8.

I would be happy to get help finding a solution.

[FEATURE]

🚀 Windows support

There is limited documentation on how to install minihack on Windows. Why do I use a minihack docker image in windows? Why can't I directly do like what I do on macOS or ubuntu system?

[BUG] Inconsistent environment seeding

🐛 Bug

Seeding doesn't consistently generate the same environment.

To Reproduce

Steps to reproduce the behavior:

  1. Run this snippet repeatedly:
env = gym.make("MiniHack-KeyRoom-Fixed-S5-v0",
    observation_keys=("pixel", "colors", "chars", "glyphs", "tty_chars"),
    seeds=(42, 42, False))
env.seed(42, 42, False)
obs = env.reset()
env.render()
print(env.get_seeds())

Sometimes this prints

Hello Agent, welcome to NetHack!  You are a chaotic male human Rogue.           
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                       ----                                     
                                       |..|                                     
                                       +(.|                                     
                                    ----..|                                     
                                    |.....|                                     
                                    |...@.|                                     
                                    -------                                     
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
Agent the Footpad              St:18/02 Dx:18 Co:13 In:8 Wi:9 Ch:7 Chaotic S:0  
Dlvl:1 $:0 HP:12(12) Pw:2(2) AC:7 Xp:1/0                                        
(42, 42, False)

But also occasionally prints (note the printed seeds are (0, 0, False)):

Hello Agent, welcome to NetHack!  You are a chaotic male human Rogue.           
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                       ----                                     
                                       |@.|                                     
                                       +..|                                     
                                       -..|                                     
                                        ..|                                     
                                        ..|                                     
                                       ----                                     
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
Agent the Footpad              St:14 Dx:18 Co:14 In:11 Wi:11 Ch:8 Chaotic S:0   
Dlvl:1 $:0 HP:12(12) Pw:2(2) AC:7 Xp:1/0                                        
(0, 0, False)

Expected behavior

Same positions of agent/key, and same seeds being printed by env.get_seeds()

Environment


MiniHack version: 0.1.3+57ca418
NLE version: 0.8.1
Gym version: 0.21.0
PyTorch version: 1.11.0+cu102
Is debug build: No
CUDA used to build PyTorch: 10.2

OS: Ubuntu 20.04.3 LTS
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
CMake version: version 3.23.1

Python version: 3.8
Is CUDA available: Yes
CUDA runtime version: Could not collect
GPU models and configuration:
GPU 0: NVIDIA GeForce RTX 3080
GPU 1: NVIDIA GeForce RTX 3080

Nvidia driver version: 510.47.03
cuDNN version: Could not collect

Versions of relevant libraries:
[pip3] numpy==1.21.6
[pip3] torch==1.11.0
[conda] torch                     1.11.0                   pypi_0    pypi

Windows user Error installing minihack with Docker

Hi, I'm trying to install minihack on windows. But after I follow the tutorial using Docker and do a pip install minihack, I get the following error:

ERROR: Failed building wheel for nle
ERROR: Could not build wheels for nle which use PEP 517 and cannot be installed directly

How can I solve this problem?

[BUG] TypeError: __init__() got an unexpected keyword argument 'archivefile'

🐛 Bug

To Reproduce

Steps to reproduce the behavior:

  1. Run the Tutorial on Google Colab
  2. Build an environment and try to print it
(https://github.com/facebookresearch/minihack/tree/main/minihack/tiles)/rendering.py

Executed line: render_des_file(des_file, n_images=1, full_screen=False)
Error message: TypeError: init() got an unexpected keyword argument 'archivefile'

Expected behavior

Normally it should print out a picture of the environment

Environment

  • MiniHack Version (e.g., 1.0): 0.1.5
  • NLE Version (e.g. 1.0): 0.9.0
  • PyTorch Version (e.g., 1.0): 0.23.0
  • OS (e.g., Linux): Mac OS
  • Python version: 3.9

Temporary solution:

I redefined the function and deleted the "archivefile=None" from the function, then it worked.

[FEATURE] Multi-agent support

🚀 Feature: Multi-agent support

Are there plans to add multi-agent support to minihack?

Motivation

Minihack is presently at a competitive advantage over other environments (e.g.: griddly, mincraft) because of its speed and the ease that new environment dynamics can be created. Adding multi-agent support would extend its complexity, flexibility, and niche on github.

Pitch

Minihack implements turn-based multiagent support (like pettingzoo's agent-environment cycle). This is what it would look like:

# hypothetical environment with a hippo, elephant, and tiger
env = gym.make("MiniHack-Zoo", ...)
env.reset()
env.step(1)  # this applies to Hippo
env.step(2)  # this applies to Elephant
env.step(3)  # this applies to Tiger
env.step(4)  # this applies to Hippo

Alternatives

MALMO provides multi-agent support, but it is slower than minihack.

[BUG] No module named 'minihack.version' when importing

When installing via pip, you get an bug after importing: "ModuleNotFoundError: No module named 'minihack.version'". This can be resolved by adding a file "version.py" with the correct info to the install directory. (version = '0.1.3+4c398d4'
git_version = '4c398d480eac26883104e867280d1d3ddbcb9a20' ).

Manual pickup multiple items

🐛 Bug

When autopickup=True the agent will attempt to pickup all the objects at a location. If I set autopickup=False, I can use the Command.PICKUP/, command to pickup the item, but if there are multiple items at that locations nothing happens. I don't see any message or prompt either. If this isn't a bug is there a work around?

To Reproduce

Steps to reproduce the behavior:

  1. Set autopickup=False
  2. Spawn two different items at a single spot
  3. Attempt to pickup using Command.PICKUP

Expected behavior

Nethack should return a prompt listing the objects available for pickup.

Environment

NLE version: 0.7.3
PyTorch version: 1.10.0+cu113
Is debug build: No
CUDA used to build PyTorch: 11.3

OS: Ubuntu 20.04.2 LTS
GCC version: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
CMake version: version 3.21.3

Python version: 3.8
Is CUDA available: Yes
CUDA runtime version: Could not collect
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 3090
Nvidia driver version: 495.29.05
cuDNN version: Could not collect

Versions of relevant libraries:
[pip3] numpy==1.21.2
[pip3] torch==1.10.0+cu113
[pip3] torchtext==0.11.0
[conda] Could not collect

Additional context

Could be a problem with nle? If this isn't a bug is there a work around?

[BUG] UnregisteredEnv error when evaluating on MiniHack-KeyRoom-Random

🐛 Bug

I'm trying to test a trained agent, using the evaluate.py script. When I specify the MiniHack-KeyRoom-Random-S5-v0 or MiniHack-KeyRoom-Random-S15-v0 environment, I get an UnregisteredEnv error.
The agent was trained using the minihack.agent.polybeast.polyhydra script, with the IMPALA algorithm and MiniHack-KeyRoom-Random-S5-v0 as env.

To Reproduce

Steps to reproduce the behavior:

  1. run the command
    python -m minihack.agent.polybeast.evaluate --env MiniHack-KeyRoom-Random-S5-v0 -c . --no-watch --max-steps 40 -n 500

This is the error that I get:
Traceback (most recent call last):
File "/home/lquarantiello/miniconda3/envs/minihack/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/home/lquarantiello/miniconda3/envs/minihack/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/lquarantiello/minihack/minihack/agent/polybeast/evaluate.py", line 300, in
main()
File "/home/lquarantiello/minihack/minihack/agent/polybeast/evaluate.py", line 296, in main
eval(**vars(flags))
File "/home/lquarantiello/minihack/minihack/agent/polybeast/evaluate.py", line 80, in eval
observation_keys=obs_keys.split(","),
File "/home/lquarantiello/miniconda3/envs/minihack/lib/python3.7/site-packages/gym/envs/registration.py", line 235, in make
return registry.make(id, **kwargs)
File "/home/lquarantiello/miniconda3/envs/minihack/lib/python3.7/site-packages/gym/envs/registration.py", line 128, in make
spec = self.spec(path)
File "/home/lquarantiello/miniconda3/envs/minihack/lib/python3.7/site-packages/gym/envs/registration.py", line 203, in spec
raise error.UnregisteredEnv("No registered env with id: {}".format(id))
gym.error.UnregisteredEnv: No registered env with id: MiniHack-KeyRoom-Random-S5-v0

Expected behavior

Run the evaluate.py script and get the result of the test

Environment

MiniHack version: 0.1.3+6a04b16
NLE version: 0.8.1
Gym version: 0.21.0
PyTorch version: 1.11.0
Is debug build: No
CUDA used to build PyTorch: 10.2

OS: Ubuntu 20.04.4 LTS
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
CMake version: version 3.22.1

Python version: 3.7
Is CUDA available: Yes
CUDA runtime version: Could not collect
GPU models and configuration: GPU 0: NVIDIA Tesla T4
Nvidia driver version: 465.19.01
cuDNN version: Could not collect

Versions of relevant libraries:
[pip3] libtorchbeast==0.0.20
[pip3] numpy==1.21.6
[pip3] torch==1.11.0
[pip3] torchaudio==0.11.0
[pip3] torchvision==0.12.0
[conda] blas 1.0 mkl
[conda] ffmpeg 4.3 hf484d3e_0 pytorch
[conda] libtorchbeast 0.0.20 pypi_0 pypi
[conda] magma-cuda113 2.5.2 1 pytorch
[conda] mkl 2021.4.0 h06a4308_640
[conda] mkl-service 2.4.0 py37h7f8727e_0
[conda] mkl_fft 1.3.1 py37hd3c417c_0
[conda] mkl_random 1.2.2 py37h51133e4_0
[conda] pytorch 1.11.0 py3.7_cuda10.2_cudnn7.6.5_0 pytorch
[conda] pytorch-mutex 1.0 cuda pytorch
[conda] torch 1.11.0 pypi_0 pypi
[conda] torchaudio 0.11.0 py37_cu102 pytorch
[conda] torchvision 0.12.0 py37_cu102 pytorch

[BUG] Error creating environment or running mh-play (Mac OSX 12.6)

🐛 Bug

Can't create environment or run play scripts in MacOSX 12.6

To Reproduce

Steps to reproduce the behavior:

  1. Install NLE 0.8.1 following workaround at facebookresearch/nle#340
  2. pip install minihack
  3. mh-play leads to error: AttributeError: 'MiniHackRoom5x5Random' object has no attribute 'env'
  4. python -m minihack.scripts.play --env MiniHack-River-v0 --mode random leads to similar error: AttributeError: 'MiniHackRiver' object has no attribute 'env'

Expected behavior

Environment created successfully

Environment

MiniHack version: 0.1.2
NLE version: 0.8.1+103c667
Gym version: 0.21.0
PyTorch version: N/A
Is debug build: N/A
CUDA used to build PyTorch: N/A

OS: Mac OSX 12.6
GCC version: Could not collect
CMake version: version 3.24.2

Python version: 3.8
Is CUDA available: N/A
CUDA runtime version: Could not collect
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: Could not collect

Versions of relevant libraries:
[pip3] numpy==1.23.3
[conda] Could not collect

Additional context

Used workaround for NLE install described here: facebookresearch/nle#340
nle-play works as expected
mh-env returns list of environments as expected.
Same error encountered with python 3.9 & 3.10, and minihack version 0.1.3 (not tested all combinations)

[BUG] minihack.scripts.play don't work on Debian 11

🐛 Bug

After installing minihack+nle to Debian 11 the following commands work:

import gym
import minihack
env = gym.make("MiniHack-River-v0")
env.reset() # each reset generates a new environment instance
env.step(1) # move agent '@' north
env.render()

But when running

python3 -m minihack.scripts.play --env MiniHack-River-v0

The program fails to errors.

To Reproduce

Steps to reproduce the behavior:

  1. Install Debian 11. Install minihack+nle (+deps) using pip install/apt-get commands.
  2. python3 -m minihack.scripts.play --env MiniHack-River-v0

Error messages/traceback:

Traceback (most recent call last):
File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.9/dist-packages/minihack/scripts/play.py", line 334, in
main()
File "/usr/local/lib/python3.9/dist-packages/minihack/scripts/play.py", line 330, in main
play(**vars(flags))
File "/usr/local/lib/python3.9/dist-packages/minihack/scripts/play.py", line 123, in play
print("Available actions:", env._actions)
File "/home/optimus/.local/lib/python3.9/site-packages/gym/core.py", line 235, in getattr
raise AttributeError(
AttributeError: attempted to get missing private attribute '_actions'

Expected behavior

One should be able to play minihack using keyboard commands.

Environment

Collecting environment information...

MiniHack version: 0.1.1
NLE version: 0.7.3
PyTorch version: N/A
Is debug build: N/A
CUDA used to build PyTorch: N/A

OS: Debian GNU/Linux 11 (bullseye)
GCC version: (Debian 10.2.1-6) 10.2.1 20210110
CMake version: version 3.18.4

Python version: 3.9
Is CUDA available: N/A
CUDA runtime version: Could not collect
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: Could not collect

Versions of relevant libraries:
[pip3] msgpack-numpy==0.4.7.1
[pip3] numpy==1.19.5
[conda] Could not collect

Additional context

No Anaconda installed.

[FEATURE] Align to gym>=0.26 API

🚀 Feature

MiniHack currently implements thegym<0.26API, which is deprecated.

Motivation

Aligning to gym>=0.26 has some ready-baked benefits, for example:

import gym.vector
import minihack

num_envs = 16
env = gym.vector.make("MiniHack-KeyRoom-Fixed-S5-v0", num_envs=num_envs)

and a step forward for gymnasium compat as well.

Pitch

The required steps are in the official migration guide:
https://gymnasium.farama.org/content/migration-guide/

Alternatives

Additional context

[BUG] tty_* observations not changing during rollout

🐛 Bug

For some reason the tty_* observations do not change during the episode, while the pixel does. Maybe I'm doing something wrong?

To Reproduce

import imageio
import minihack
import gym
from IPython.display import Video

env = gym.make("MiniHack-Room-Random-15x15-v0", observation_keys=["pixel_crop", "tty_chars"])

obs = env.reset()
done = False

images = [obs["pixel_crop"]]
first_tty = obs["tty_chars"]

while not done:
    action = env.action_space.sample()
    obs, reward, done, _ = env.step(action)
    images.append(obs["pixel_crop"])
    
(first_tty - obs["tty_chars"]).sum()  # this always 0 for me which is just impossible as actor is definitely moving and not standing still

imageio.mimsave("rollout.mp4", images, fps=16, format="mp4")
Video("rollout.mp4")
rollout.mp4

Expected behavior

At least tty_chars should be changing as actor is moving ("@" char), as well as tty_cursor, as it should be on actor by default (probably).

Environment

MiniHack version: 0.1.4
NLE version: 0.9.0
Gym version: 0.23.0
PyTorch version: 2.0.0
Is debug build: No
CUDA used to build PyTorch: None

OS: Mac OSX 13.2.1
GCC version: Could not collect
CMake version: version 3.25.2

Python version: 3.9
Is CUDA available: No
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA

Versions of relevant libraries:
[pip3] functorch==2.0.0
[pip3] numpy==1.23.4
[pip3] torch==2.0.0
[pip3] torch-ac==1.4.0
[pip3] torchvision==0.14.1
[conda] functorch 2.0.0 pypi_0 pypi
[conda] torch 2.0.0 pypi_0 pypi
[conda] torch-ac 1.4.0 pypi_0 pypi
[conda] torchvision 0.14.1 pypi_0 pypi

Is it possible to generate pixel images (ideally cropped) in a desired resolution?

Right now, I use opencv as

env = gym.make(env, observation_keys=("pixel_crop",), penalty_step=0.0)
obs_dict, reward, done, info = env.step(action)
image = cv2.resize(obs_dict['pixel_crop'], dsize=(64, 64), interpolation=cv2.INTER_LINEAR)

I'm wondering if it's possible to avoid this resizing by just directly rendering in the desired resolution.

[QUESTION] any way to respawn the agent after death

Is there any way with des format or some internal tools not to end the episode after death, but to revive the agent at the starting position of the spawn?

For context, I want to make an additional environment to test the agent's memory. For example, fill everything with lava, then add a corridor from one start point to the end point, but limit the agent's FOV. In order to solve it, the agent would have to randomly try directions, dying in the lava and reviving, but remembering the previously opened corridor cells (to eventually get to the end point).

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.