A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: A* Pathfinding

Threaded View

  1. #1
    An FKer
    Join Date
    Sep 2005
    Location
    Ontario
    Posts
    1,167

    A* Pathfinding

    Okay, I'm definitely missing something and it's really bothering me, haha. So I guess it's time to take it to the forums!

    So this is my general summary of how I understand A* Pathfinding. Note that I'm only looking at horizontal/vertical surrounding tiles, therefore eliminating the need for G.

    That means, I'm working with the formula: F=H, where H is the estimated distance from the current tile being looked at to the destination tile without taking into consideration impassible tiles.



    So lets take a simple example:


    The blue tile represents the current on tile, and for right now is the starting tile (or character location). The red tile represents the destination tile, and the black ones are impassible tiles.



    Examining the surrounding tiles of the current tile, we see the following H values of each:



    We then take the shortest one, that is, the closest tile to the destination and add it to an array we can call pathHold. So now we repeat the process from this now new current tile:




    This is where my issue begins. We now see that we have a matching H value, but visually it's obvious that the lower tile is the best route to take to the destination.

    However, how do you determine which is the best one via code? And what generally happens is this result:



    Sometimes it'll just take the wrong path, and because it made that bad choice at the 'fork in the road', it'll start going the long way around basically going through each tile.


    What exactly am I not doing, or taking into consideration?
    Last edited by Osteel; 03-30-2010 at 03:16 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center