facebookresearch / minihack Goto Github PK
View Code? Open in Web Editor NEWMiniHack the Planet: A Sandbox for Open-Ended Reinforcement Learning Research
License: Apache License 2.0
MiniHack the Planet: A Sandbox for Open-Ended Reinforcement Learning Research
License: Apache License 2.0
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!
Are there plans to add multi-agent support to minihack?
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.
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
MALMO provides multi-agent support, but it is slower than minihack.
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.
Steps to reproduce the behavior:
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()
Scripting launching a gui window.
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
None
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
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
Linux Mint 20.2
Python 3.8.12
conda 4.10.3
Minihack does not work with NLE v0.9.0
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'
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.
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)
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
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
.
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
int(info["end_status"])
should be -1
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.
Could we populate the level with a standard level that demonstrates the individual building blocks (like the one used on the readme)? Could we also have a "clear level" button to get to the empty level that is currently shown when calling https://minihack-editor.github.io/
The flake8 repository has been moved from gitlab
For some reason the tty_*
observations do not change during the episode, while the pixel does. Maybe I'm doing something wrong?
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")
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).
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
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.
Steps to reproduce the behavior:
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
Run the evaluate.py script and get the result of the test
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
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.
Steps to reproduce the behavior:
Do you want to help me? We could do useful co-operation?
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
conda
, pip
, source):I have born in 1980 and Finland killed me for no good reason.
Contact me: [email protected]
Boxoban data is being downloaded in the wrong folder.
Steps to reproduce the behavior:
The reason probably is that Boxoban env is looking for data in the wrong folder:
minihack/minihack/envs/boxohack.py
Lines 11 to 13 in 2989b3b
For some reason it expects the data to be in nle package, while it's being downloaded to the minihack package folder.
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
Steps to reproduce the behavior:
MONSTER
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)
Env consists of map described is des file
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
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.
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:
No FileNotFoundError when running our RL algorithm on MiniHack.
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
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?
Seeding doesn't consistently generate the same environment.
Steps to reproduce the behavior:
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)
Same positions of agent/key, and same seeds being printed by env.get_seeds()
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
Can't create environment or run play scripts in MacOSX 12.6
Steps to reproduce the behavior:
mh-play
leads to error: AttributeError: 'MiniHackRoom5x5Random' object has no attribute 'env'python -m minihack.scripts.play --env MiniHack-River-v0 --mode random
leads to similar error: AttributeError: 'MiniHackRiver' object has no attribute 'env'Environment created successfully
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
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)
Reward Manager expects environment to have _actions
rather than actions
.
Steps to reproduce the behavior:
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
current polybeast implementation has most code written in C++, requesting for mnonobeast implementation for more clarity
readability/flexibility
monobeast implementation will offfer more readability and flexibility
N/A
N/A
Upgrading from the (by now pretty old) gym version to gymnasium.
Better usability of MiniHack with standard training libraries like SB3.
Since gymnasium is becoming the default in more and more training libraries, it would be great to be able to use MiniHack in gymnasium.
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.
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.
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' ).
MiniHack currently implements thegym<0.26
API, which is deprecated.
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.
The required steps are in the official migration guide:
https://gymnasium.farama.org/content/migration-guide/
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?
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.
Steps to reproduce the behavior:
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'
One should be able to play minihack using keyboard commands.
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
No Anaconda installed.
Using the bionic docker image, attempting to install and run the rllib agents results in errors.
Steps to reproduce the behavior:
I then get the following error:
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:
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!
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
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
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.
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.
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?
Steps to reproduce the behavior:
autopickup=False
Command.PICKUP
Nethack should return a prompt listing the objects available for pickup.
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
Could be a problem with nle? If this isn't a bug is there a work around?
Steps to reproduce the behavior:
Executed line: render_des_file(des_file, n_images=1, full_screen=False)
Error message: TypeError: init() got an unexpected keyword argument 'archivefile'
Normally it should print out a picture of the environment
I redefined the function and deleted the "archivefile=None" from the function, then it worked.
The link for the paper "Hierarchical Kickstarting for Skill Transfer in Reinforcement Learning" is wrong. It's currently the link for "Replay-Guided Adversarial Environment Design".
The correct link is: https://arxiv.org/abs/2207.11584
minihack.readthedocs.io is out of date. For example, search for env._actions
in the reward manager docs, compared to the reward manager file. It has been renamed to env.actions
however the docs don't reflect this.
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.
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.
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.
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.
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.
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.
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
Single line changes to each of the environments. I do not think these are large enough to warrant testing or API changes.
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?
Could you please release the source code for the minihack editor?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.