Dijkstra's Algorithm and Turn Based Strategy

0 favourites
  • 6 posts
From the Asset Store
Finding the shortest path through the cells based on the A-star algorithm
  • Hi all,

    I've been playing around with c2 for a few weeks now and would like to attempt making a turn based strategy.

    Thats a bit broad so let me narrow it down. A turn based strategy similar to Advance Wars takes into account immovable terrain and terrian with varying cost.

    I've been told in order to workout how far a unit/character can move on a square grid based map with terrain penalties I would need to use Dijkstra's Algorithm.

    I'm scratching my head at how to implement this as I'm finding it difficult to understand the psuedo code.

    cprogramming.com/tutorial/computersciencetheory/dijkstra.html

    Can someone help explain this to me or point me at a simpler psuedo code for Dijkstra's Algorithm.

  • You could use built-in pathfinding behavior, I recall they added features to support movement cost.

  • You could use built-in pathfinding behavior, I recall they added features to support movement cost.

    I've had a look at the pathfinding demo and it's not quite what I'm after. It seems that they create an event based on overlapping with an obstacle sprite and then reduce the maximum speed of the moving unit. The path cost feature seems to encourage a path to be avoided rather than making the path not possible. Also it seems to cut corners even with diagonals disabled.

    Can I restrict the pathfinding movement to move in only 90 degree angles and not allow movement to a destination if the path cost value exceeds a threshold?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • "Can I restrict the pathfinding movement to move in only 90 degree angles and not allow movement to a destination if the path cost value exceeds a threshold?" > Any answer for that? I am making a game like Shining Force 2 and my characters need to not cut corners. I also need straight angles.

  • Harlequin

    check out this thread from yesterday: https://www.scirra.com/forum/how-do-i-do-custom-pathfinder-for-hex-maps_t152368

    R0J0hound wrote an outstanding example of how to implement the A* algorithm - which is similar to Dijkstra's Algorithm

  • This example here is applicable, although I forget if varying costs is implemented in it.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)