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

Fix Infinite Looping in Level Generation #5

Closed
sunjay opened this issue Oct 14, 2018 · 1 comment
Closed

Fix Infinite Looping in Level Generation #5

sunjay opened this issue Oct 14, 2018 · 1 comment

Comments

@sunjay
Copy link
Owner

sunjay commented Oct 14, 2018

Sometimes level generation takes an infinite amount of time because something that it is trying to do is actually impossible, regardless of how many times we loop. To fix this, we need to pass in a number of attempts to the MapGenerator and replace our loop statements with limited loops. When we reach the limit, we should return an Err to indicate that something failed. When such an error propagates up, we should use the same rng to generate another MapKey and then try again using that.

A consequence of this strategy is that some MapKeys will actually collide with other MapKeys. Not a huge deal though because we aren't doing cryptograph hashing. It's more important that we actually eventually return a map and do not loop forever.

We should fatally error if 5 MapKeys don't work in succession. That would be a hell of an edge case...

@sunjay
Copy link
Owner Author

sunjay commented Oct 19, 2018

Fixed in a154820

@sunjay sunjay closed this as completed Oct 19, 2018
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

No branches or pull requests

1 participant