Pathfinding Code Produces Unexpected Results
First of all, excuse the bad title, but I don't know how to describe this in just one sentence... Given a grid with 3 kinds of fields, empty fields, walls and exits, I wrote a prog
Solution 1:
I suspect your issue is a common Python gotcha. This line:
def alle_parents(knoten, parents = []):
Creates an empty array when the module is loaded, NOT every time the function is called. Future calls to alle_parents() will reuse the same array (which may have grown in size) instead of a new empty array! A good way to fix is to do this:
def alle_parents(knoten, parents = None):
parents = parents or []
Post a Comment for "Pathfinding Code Produces Unexpected Results"