Add assertion for maze constraints and limit _random_floor_cell attempts #515
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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_cellfunction, since it uses awhile Trueloop.This PR adds an additional assertion check in
maze.pyand additionally limits the number of tries the_random_floor_cellfunction can perform before raising a RuntimeErrorSteps to reproduce:
The generation would stall and run indefinitely