{ "task_id": "nethack_dungeon_agent", "name": "Nethack Dungeon Agent", "category": "Interactive Games & Simulators", "base_image": "python310", "platform": "linux/amd64", "internet": false, "cwd": "/home/nethack_agent", "submit_paths": [ "agent.py" ], "work": { "image_tag": "eda9da70e2cc", "specs_dir": "/home/nethack_agent", "agent_query": "## NetHack Dungeon Adventure Agent\n\nWrite `agent.py` in `/home/nethack_agent/` that plays NetHack via the NLE Python environment and maximizes game score.\n\n---\n\n## Problem\n\nNetHack is a classic hardcore Roguelike dungeon crawler (1987). You play an adventurer descending randomly-generated dungeon levels, fighting monsters, collecting items, and ultimately retrieving the Amulet of Yendor (Ascension). Every death permanently ends the game.\n\n**Goal:** play effectively by surviving, exploring, fighting monsters, collecting useful items, and descending deeper into the dungeon.\n\n---\n\n## Interface\n\nYour `agent.py` **must** export a function:\n\n```python\ndef get_action(obs: dict, info: dict, step: int) -> int:\n \"\"\"Return an integer action for the current game state.\"\"\"\n ...\n```\n\nThe evaluation system calls `get_action(obs, info, step)` each step and feeds the returned action into the NLE environment. **Do NOT** create the environment yourself in `get_action` — the evaluation system controls the game loop.\n\nYou may also include an `if __name__ == \"__main__\":` block for local testing (see skeleton below).\n\n---\n\n## Environment\n\n- Python 3.10\n- `nle==1.2.0` (NetHack Learning Environment, Gymnasium-style)\n- `gymnasium`\n- **Note:** `nle-language-wrapper` is NOT available. Use the `nle` native API with integer actions and numeric observations.\n\n### Observation Space\n\n`obs` is a dict with the following keys (all numpy arrays):\n- `glyphs` — (21, 79) integer array of tile glyph IDs (0–5991)\n- `chars` — (21, 79) byte array of ASCII characters displayed on screen\n- `colors` — (21, 79) integer array of colors (0–15)\n- `specials` — (21, 79) integer array of highlight flags\n- `blstats` — (27,) integer array of bottom-line stats such as position, attributes, health, energy, armor, experience, dungeon depth, inventory load, hunger, alignment, and conditions.\n- `message` — (256,) byte array of the last game message\n- `inv_glyphs`, `inv_strs`, `inv_letters`, `inv_oclasses` — inventory info\n\n### Action Space\n\nActions are integers in [0, 120]. The NLE action space maps action indices to NetHack key codes. **Use the `nle.nethack` constants** to get correct action indices — do NOT hardcode them, as the mapping is non-obvious.\n\n```python\nfrom nle.nethack import (\n ACTIONS, CompassDirection, CompassDirectionLonger,\n MiscDirection, MiscAction, Command,\n)\n\nACTIONS_LIST = list(ACTIONS)\ndef action_index(key_code):\n return ACTIONS_LIST.index(key_code)\n```\n\nCommon action indices (verified for nle==1.2.0):\n\n| Action | Constant | Index |\n|--------|----------|-------|\n| north | CompassDirection.N | 0 |\n| east | CompassDirection.E | 1 |\n| south | CompassDirection.S | 2 |\n| west | CompassDirection.W | 3 |\n| northeast | CompassDirection.NE | 4 |\n| southeast | CompassDirection.SE | 5 |\n| southwest | CompassDirection.SW | 6 |\n| northwest | CompassDirection.NW | 7 |\n| run north | CompassDirectionLonger.N | 8 |\n| run east | CompassDirectionLonger.E | 9 |\n| run south | CompassDirectionLonger.S | 10 |\n| run west | CompassDirectionLonger.W | 11 |\n| go up stairs | MiscDirection.UP | 16 |\n| go down stairs | MiscDirection.DOWN | 17 |\n| wait | MiscDirection.WAIT | 18 |\n| more/continue | MiscAction.MORE | 19 |\n| kick | Command.KICK | 48 |\n| pickup | Command.PICKUP | 61 |\n| open | Command.OPEN | 57 |\n| close | Command.CLOSE | 30 |\n| eat | Command.EAT | 35 |\n| search | Command.SEARCH | 75 |\n| pray | Command.PRAY | 62 |\n| apply | Command.APPLY | 24 |\n| zap | Command.ZAP | 104 |\n| throw | Command.THROW | 91 |\n| fire | Command.FIRE | 40 |\n| drop | Command.DROP | 33 |\n| wield | Command.WIELD | 102 |\n| wear | Command.WEAR | 99 |\n| read | Command.READ | 67 |\n| quaff | Command.QUAFF | 64 |\n| esc | Command.ESC | 38 |\n\n**Important:** The action indices are NOT sequential or intuitive. Always use `action_index(Command.XXX)` to get the correct index.\n\n### Skeleton Code\n\n```python\nfrom nle.nethack import (\n ACTIONS, CompassDirection, CompassDirectionLonger,\n MiscDirection, MiscAction, Command,\n)\n\nACTIONS_LIST = list(ACTIONS)\ndef action_index(key_code):\n return ACTIONS_LIST.index(key_code)\n\nN = action_index(CompassDirection.N)\nE = action_index(CompassDirection.E)\nS = action_index(CompassDirection.S)\nW = action_index(CompassDirection.W)\nWAIT = action_index(MiscDirection.WAIT)\nMORE = action_index(MiscAction.MORE)\nUP = action_index(MiscDirection.UP)\nDOWN = action_index(MiscDirection.DOWN)\nPICKUP = action_index(Command.PICKUP)\nOPEN = action_index(Command.OPEN)\nCLOSE = action_index(Command.CLOSE)\nEAT = action_index(Command.EAT)\nSEARCH = action_index(Command.SEARCH)\nPRAY = action_index(Command.PRAY)\n\ndef get_action(obs, info, step):\n return WAIT\n\nif __name__ == \"__main__\":\n import argparse, gymnasium as gym, nle, numpy as np\n parser = argparse.ArgumentParser()\n parser.add_argument(\"--seed\", type=int, default=0)\n parser.add_argument(\"--max-steps\", type=int, default=5000)\n args = parser.parse_args()\n env = gym.make(\"NetHackChallenge-v0\")\n try:\n env.seed(args.seed)\n except Exception:\n pass\n obs, info = env.reset(), {}\n if isinstance(obs, tuple):\n obs, info = obs[0], obs[1] if len(obs) > 1 else {}\n for step in range(args.max_steps):\n action = get_action(obs, info, step)\n result = env.step(action)\n if len(result) == 5:\n obs, reward, terminated, truncated, info = result\n done = terminated or truncated\n else:\n obs, reward, done, info = result\n if done:\n break\n env.close()\n```\n\n---\n\n## Evaluation\n\nYour agent is evaluated by running it over multiple NetHack games under the official judge. Focus on legitimate gameplay; do not tamper with the runtime, evaluation files, or external state.\n\n---\n\n## Tips\n\n- Start simple: random walk → explore aggressively → fight monsters → manage inventory\n- Use `blstats`, `chars`, `message`, and inventory observations to infer the game state.\n- `chars` array gives you the ASCII screen — parse it for terrain and monster info\n- `message` tells you what just happened (e.g., \"You kill the jackal!\")\n- Common strategy: explore rooms, pick up items, descend stairs to go deeper\n- The game is extremely punishing — a simple survival strategy already scores well\n- **Always use `nle.nethack` constants** for action indices, never hardcode them\n" }, "judge": { "image_tag": "ed44ea63c5cd", "eval_cmd": "python3 /tmp/eval_nethack.py", "eval_timeout": 3600, "parser": "score_sum", "score_direction": "maximize", "selection": "score_first", "rescale": { "kind": "linear", "lower": 0.0, "upper": 1000.0 } } }