vleue / polyanya

Pathfinding using Polyanya
Apache License 2.0
260 stars 18 forks source link

Avoid infinite loop #44

Closed MJohnson459 closed 9 months ago

MJohnson459 commented 9 months ago

Workaround for https://github.com/vleue/polyanya/issues/45.

In some cases I was getting an infinite loop happening. This PR adds a limit to the loop to avoid this situation.

I'm not sure what a reasonable value for the limit is. I chose the number of polygons as I'm assuming that checking every polygon should not happen in normal circumstances (is that true?).

Note that this doesn't fix the cause of the loop, it only adds a failure condition to avoid crashing.

MJohnson459 commented 9 months ago

Ok I hit a case where using self.polygons.len() was too small and exited early when it shouldn't have. I could just make this * 1000 but maybe there is a smarter way? Maybe that is fine for a quick band-aid while we look for the root cause.