Dijkstra's Algorithm and Turn Based Strategy

Get help using Construct 2

Post » Tue Apr 30, 2013 10:50 am

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.

http://www.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.
B
6
S
1
Posts: 19
Reputation: 544

Post » Tue Apr 30, 2013 12:10 pm

You could use built-in pathfinding behavior, I recall they added features to support movement cost.
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Tue Apr 30, 2013 12:55 pm

[QUOTE=vee41] You could use built-in pathfinding behavior, I recall they added features to support movement cost.[/QUOTE]

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?Harlequin2013-04-30 12:59:44
B
6
S
1
Posts: 19
Reputation: 544

Post » Thu Aug 20, 2015 10:05 pm

"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.
B
9
S
4
G
1
Posts: 18
Reputation: 1,315

Post » Fri Aug 21, 2015 1:20 am

@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
B
52
S
16
G
10
Posts: 342
Reputation: 9,569

Post » Fri Aug 21, 2015 6:24 am

This example here is applicable, although I forget if varying costs is implemented in it.
sequential-grid-span-class-posthilit-based-span-movement_p695580?#p695580
B
79
S
24
G
53
Posts: 4,735
Reputation: 40,233


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 15 guests