Skip to content

Conversation

@Gjorgji-Noveski
Copy link

During maze generation in game environments, an issue can occur if the min_grid_size -2 is not >= min_dist. This can cause an invalid maze layout to be generated in which there is no place to put starting cell and goal cell on the grid. This happens because the outer borders of the grid are used as walls to constrain the agent.

Given the following maze configuration:
size=6, min_dist=2, max_dist=10, min_grid_size=3, max_grid_size=12, seed=1
the following maze would be generated before placing any (Start) and (Goal) cells:

image

Under these conditions, it is not possible to place the start and goal cells.

Additionally there is no guard against infinite loop in the _random_floor_cell function, since it uses a while True loop.

This PR adds an additional assertion check in maze.py and additionally limits the number of tries the
_random_floor_cell function can perform before raising a RuntimeError

Steps to reproduce:

import reasoning_gym

data = reasoning_gym.create_dataset("maze", size=6, min_dist=2,
                                    max_dist=10, min_grid_size=3,
                                    max_grid_size=12, seed=1)

print(list(data))

The generation would stall and run indefinitely

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant