facebookresearch/minihack

Manual pickup multiple items

Closed this issue ยท 6 comments

๐Ÿ› 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?

I'm inheriting from MiniHackSkill.

class BaseTask(MiniHackSkill):
    def __init__(self, max_steps, des_file, **kwargs):
        super().__init__(
            des_file=des_file,
            max_episode_steps=max_steps,
            penalty_step=0,
            observation_keys=(
                "screen_descriptions", 
                "chars",
                "colors",
                "specials",
                "inv_strs", 
                "inv_letters", 
                "message", 
                "blstats"
            ),
            actions=nle.nethack.ACTIONS,
            autopickup=False,
            **kwargs
        )

Hi @kolbytn. This is due to the fact that in the game of NetHack when two objects are at the same location, then the PickUp action is performed through "menus". This is disabled on minihack environments by default. To enable it, simple pass allow_all_modes=True to the environment and minihack will initialise nle accordingly. I'd recommend playing (with mh-play) with this mode enabled to see how to solve this version of the environment as a human.

Just note that this will change how the agent interacts with the environment. Specifically, nle will no longer automatically perform known steps. This means, for instance,if the agent pressed i for opening the inventory, it will need to press ESC to continue.

Hope this helps. Let me know if you have any further questions.

Thank you for the information. Is it possible to get those prompts to appear somewhere in the observation? I see them using self.render() but they don't appear as part of the message observation.

Yes, please take a look at the tty_ observations. These return the terminal state of the game, similar to how humans play the game. For more information, see this documentation page.

Closing the issue. Feel free to reopen if there are further questions.