Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Sokoban crash bug #7

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

BartekCupial
Copy link

Associated issue: #4

Description

This PR fixes a crash in the Sokoban environments when the agent character (@) disappears from observation. The crash occurs because _object_positions() returns an empty list when the agent is not found, causing an IndexError when accessing the first element

Changes Made

  • fixed index error which occured in death screen agent_pos = next((pos for pos in self._object_positions(observation, "@")), None)
  • added food to all maps (the same amount as in nle), because some maps are impossible to solve without first starving to death
  • changed action space so we can interact with food (PICKUP, EAT)

Testing

  • Verified crash is fixed with MiniHack-Sokoban1b-v0
import minihack
import gymnasium as gym

env = gym.make("MiniHack-Sokoban1b-v0")

env.reset()
env.render()
done = False

while not done:
    obs, rew, term, trun, info = env.step(env.action_space.sample())
    done = term or trun
    env.render()

Closes #4

@github-actions github-actions bot added the envs label Feb 13, 2025
@BartekCupial
Copy link
Author

@samvelyan can we merge this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Sokoban envs crash consistently
1 participant