• Content count

  • Joined

  • Last visited

Community Reputation

102 Neutral

About SinusPi

  • Rank
  1. Well, without a node link to (next to) the target point the portals wouldn't be portals at all Of course they have them. And the child node would have its heuristic show as very optimistic.
  2. Hum. Minimum of goals or portals, you say... Now that's a thought. That actually answers a different question - "how to get a perfect path even when portals are involved". However, maybe this renders my dilemma moot. Interesting, will give it a spin. Thank you.
  3. A* "for dummies", in intuitive terms

    Um, actually, A* burns the silly hicks faster, even resorting to cheating
  4. I find few things as infuriating as algorithms that are always explained in pseudocode and graphs, while there are quite intuitive real-world similes, allowing for a much easier learning curve. Such an example can be very easily used to describe Dijkstra's pathfinding, and expanded to A*. Those of you that wrote tutorials of your own, feel free to either correct my metaphor, or use it if you find it correct enough. Those of you that haven't quite grasped how those algorithms work, and are just struggling to make their pathfinder work at all, I hope this helps a bit. It's Dijkstra and A* for coders at kindergarten level. If you're an old pro, don't say it's obvious, it wasn't obvious for me until I pictured it like this. So, here goes. Consider a volcano, all teeming with lava, and a village near its base, pretty unlucky, if you ask me. The crater, full of white-hot lava, is the starting point; the village is the destination. We need to find out how fast can lava bring fiery armageddon to the village. Now, in this virtual volcano, lava spreads in turns. At any moment in time, lava will pour from exactly one place onto spots around and below it - and the hotter the lava is, the easier it flows, so at any moment the hottest spot flows out to spots below... and the original spot cools completely, while the spots lava flowed onto retain some temperature: the closest, steepest spots were reached faster, so lava is hotter there than in far, slightly sloped areas. Of course, initially the crater is the only hot spot. In subsequent turns, lava from the hottest spots flows out... and out... cooling off, while the expanding edge is still pretty warm... until it reaches the village somewhere out there and reduces it to cinder. As soon as it does, we can see where lava flowed from - look at photos of lava flows, the flow direction is often easily seen! - so we can backtrack from the village onto the crater. Presto, the lava always took the easiest route, so it found the easiest path for us. This is Dijkstra. Spots with hot lava = open nodes. Spots cooled = closed nodes. Terrain slope = cost. Lava temperature = cost of current path. How do we burn this damn hamlet faster? Mind-bogglingly easy: we temporarily tilt the volcano towards the village, and push the village into a valley. Yes, the village is really out of luck this time. Yes, the lava can now flow differently, which may result in a longer path once we straighten the volcano and the village again (the terrain-bending was only temporary). But it should take it less turns to make crispy peasants. A* right there. We have the volcano and the lava and everything, we just add a tilt, so that the lava has extra incentive to flow towards the village, rather than away from it. That's the heuristics magic. Good luck burning those huts!
  5. [quote name='japro' timestamp='1327406586' post='4905760'] It will just always try the "most obvious" path first which may allow it to terminate early. [/quote] "May" allow? If I don't allow and just proceed, my ending node ends up on the closed list, and the search never again completes. If I leave it on the open list, though, it's constantly "licked at" from neighboring nodes, which are trying to find a better solution (but if the heuristic was good, these are worse than the first found beeline path). Do you mean that I should allow it anyway, thus wasting a lot of time for the nodes to "lick" at the end node, so that finally the move "backing away" from the end direction, and into the "portal", is considered? But even then, the portal will only lead to an already checked (and, thus, closed) node...
  6. [quote name='Hodgman' timestamp='1327379928' post='4905683'] A* [i]will [/i]find the shortest path, assuming your heuristic is "admissible" ([i]it never overestimates the minimal cost of reaching the goal[/i]). [/quote] Actually, I don't think it will: in a complex map where a direct portal (leading right next to the target point) lies just behind the starting point, no A* variant that I know of will ever knowingly move away from the target, unless it's stuck. So when there's a (mediocre) beeline from start to end, A* will never think of moving in the completely opposite direction, in hopes of finding a perfect shortcut from there. And this IS the kind of map that I'm working on - shortcuts and teleports and wormholes all over. Hence, no heuristic (that I know of) can be good enough. Iterative deepening, though, looks like a series of A* runs, just with a narrowing acceptable cost - however, how exactly do I prevent the accepting of a too-costly solution? By never closing nodes whose total cost has already exceeded the allowed cost, perhaps, and just dropping them? Also, how does that prevent the problem I described, where a heuristically "more interesting" node has already been seen (and thus, closed), and later somehow a shortcut leading directly to that node is found, exceeding the heuristic expectations? In my experience, the shortcut is ignored, since that node is in the closed list. Or, should nodes be taken out of the closed list, if cheaper paths to them are found? But, wouldn't that massively increase calculation time, with each interesting shortcut forcing the recalculation of a significant part of the map?
  7. I'm looking for a way to smoothly present path improvement, starting from A* to a regular Dijkstra. I'm operating under an assumption that A* with its heuristics will find a path fast, while Dijkstra's will find the best path ever, though it might take significantly longer. Basically, I need my pathfinder to find (some) path immediately, with an option to improve it over the next second or two. Obviously gradual reducing the heuristic towards-the-target bias should do the trick, but at the unacceptable cost of recalculating every-damn-thing at each pass. I tried making A* not stop at a first found end node edge, and not putting the end node on the closed nodes list, but that resulted in the algorithm frantically hopping around the end node, trying to get at it from different angles. Also, nodes once visited in a seemingly good, but ultimately sub-optimal path (costly in terrain, but good in heuristics) were never visited again (closed list prevented that, naturally) even if backing away a bit from the proper direction resulted in finding a perfect shortcut path (very cheap terrain-wise, but not promising as far as heuristics go). So, here's my puzzle: is there a known combination of these algorithms, capable of somehow gradually reducing the use of heuristics? Perhaps by some clever "reviving" of closed nodes if they prove to be reachable faster (though when I tried it, it kept reviving all nodes around the goal, for some reason)..?