I'm a Javascript developer learning Go and am currently trying to implement A* as a maze solver. Here's my first stab (input maze comes from this Daily Programmer challenge):
It seems like I've gotten the algorithm implementation correct, as I'm finding the target node with various inputs, but I can't seem to get reconstructPath to work. I have a really nagging hunch that this has to do with pointers/dereferencing/passing by reference vs passing by value in my assignment of cameFrom, but I can't for the life of me puzzle it out. For instance, the inputs:
start := maze.Nodes[1][1]
end := maze.Nodes[1][3]
path, _ := maze.FindPath(start, end)
fmt.Println(path)
in my main goroutine output
[{1 3 0xc42000fa20 0 0 . <nil>}]
Can anyone spot the errors/problems in my approach?