Menu

How to correctly set cost?

Help
2006-07-20
2013-04-23
  • Lee Thomason

    Lee Thomason - 2006-07-20

    "...each tile has a cost associated with it.  And because of that I can't just say that horizontal/vertical lines have a cost of 1.0, and diagonals have a cost of 1.41 - the costs change because there are several different types of terrain with different costs..."

    The 1.0/1.4 approach reflects the distance to the next tile. Therefore when MicroPather runs, it is actually minimizing the distance.

    If a 'hill' tile takes twice the time of a 'grass' tile to cross, then the time for a hill is 2.0/2.8 and grass is 1.0/1.4. Using those numbers, running MicroPather will give you a path of the minimum time.

    The units and quantity don't matter - MicroPather will minimize for whatever system you give it.

    "...So essentially my question is how do I change the costs.  In the AdjacentCost function I see there's an array called "cost"..."

    Once you call 'Solve()' your application will get called back with the AdjacentCost method. For a give tile (in this case) it *must* return consistent values, else the solution will not be correct. If you need to switch your pathfinding mode for distance to time (or whatever) then call the Reset() function, and all the saved state will be thrown away. But between calls to Reset(), you have to return consistent results.

    lee

     
    • Keith Weatherby II

      Okay i'm still confused a bit.  The tile cost is in terms of turns, like in a board game.  It isn't actual distance.  Also if I were to change the values in the cost array (even calling Reset() after every time)would this break the pather?  When you say consistant between calls that means that all the items in the array must be the same every time?  Also how do I know which "states" correspond witch which array elements.  (Like if I put in the cost for a grass tile, but then a diagonal had a hill tile, i'd need to know what diagonal to change).

      Or am I just totally missing the point here?

      Maybe it doesn't do what I want to do.

      Thanks again for your time.
      Keith

       

Log in to post a comment.