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.
What does this PR do?
This PR implements a procedural environment for finding the largest island in a binary grid (a popular Leetcode interview question).
An island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical). One may assume all four edges of the grid are surrounded by water. The area of an island is the number of cells with a value 1 in the island.
The islands are generated with random walks starting from random positions in a grid initialized with 0's.
The result is obtained by doing Breadth First Search (BFS) from each position where there's a 1, without repeating already visited cells.
Because of the stochastic nature of the generation and merging of generated islands, it would be very hard to guarantee the actual minimum number of generated islands. Same reasoning can be applied for why it's hard to guarantee the maximum size for an individually generated island.
Nonetheless, I believe having a stricter upper bound on the number of generated islands (
max_num_islands
) is of largest importance for curriculum learning, hence why I didn't pursue these limitations any further.Example usage