Re: A* Search in Lua/Love
Posted: Thu Jan 12, 2012 4:52 pm
It might seem like that's the case, but A* doesn't work that way. Once it explicitly tests a node, it removes it from the "open list," which is where it would look for a new node to test. So A* doesn't backtrack in this scenario.coffee wrote:I agree with Robin, there is a very strange delay even that the path have a lot of steps. The engine shouldn't take so long calculating since the engine haven't real alternatives or new bifurcations to compare with old path. But the engine is probably rechecking after a new step again and again if tiles in his "back" are still an alternative.
I think I found out what the problem was, and it might have little to do with the actual algorithm (though I still will probably optimize that). I have a function called "flattenMap()" which I threw in to allow for updates in the layout. Right now, it loops through the entire map, every time, before the start of the search, and like a big hand, rubs itself all over the map, checking every boolean toggle and comparing it to the boolean toggle on the "visual" map. The reason I think this is the issue is because walls were a part of my flattenMap(), and it needed to switch the wall toggle on for half the nodes on the map, every dt (during the speed test).
I can probably optimize this by only doing the big sweep once, and then sniping only the toggles that matter. This might take some time, because I'll probably end up rewriting a big portion of the A* neighbor check.