My friend and I are trying to redo the pathfinding for our 2-d RPG but we are having trouble getting the algo to work properly, We went through a tutorial so we understnad how the algorithm works but not how to implement it properly

We are trying to make a script that can take a 2d array of (0's are empty, 1's are filled with an obstacle) and a start and finish and return a list of points creating the shortest path

Can you also post some example input?I tried running it, but I get an IndexError and I don't feel like figuring out the correct input format.What I can say from taking a quick look at your code is you're overcomplicating a lot of very simple things.

stranac wrote:Can you also post some example input?I tried running it, but I get an IndexError and I don't feel like figuring out the correct input format.What I can say from taking a quick look at your code is you're overcomplicating a lot of very simple things.

Here you can download this and it has test_data.txt for an example array

while len(open_set): lowest_fscore = [(fscore[item], item) for item in open_set] lowest_fscore.sort() current = lowest_fscore[0][1] if current == goal: data = [] while current in came_from: data.append(current) current = came_from[current] return data

while len(open_set): lowest_fscore = [(fscore[item], item) for item in open_set] lowest_fscore.sort() current = lowest_fscore[0][1] if current == goal: data = [] while current in came_from: data.append(current) current = came_from[current] return data

while len(open_set): lowest_fscore = [(fscore[item], item) for item in open_set] lowest_fscore.sort() current = lowest_fscore[0][1] if current == goal: data = [] while current in came_from: data.append(current) current = came_from[current] return data