A * pathfinding in construct

Get help using Construct 2

Post » Fri Aug 23, 2013 11:35 am

I originally posted this in my projects devlog but since i need help i decided to post it here as well in the hope it gets more views.

I coded a A * pathfinding engine in construct.



The only problem is that its slow at the moment. I hope some one can have a look at the source and suggest how i could speed it up.

Heres the Demo. It will start working as soon as it loads. Give it a few seconds to find the path.

And here is the Source.
B
43
S
23
G
20
Posts: 735
Reputation: 12,027

Post » Fri Aug 23, 2013 2:38 pm

@Ethan

Cant open any of your links.
B
79
S
22
G
14
Posts: 389
Reputation: 12,324

Post » Fri Aug 23, 2013 2:58 pm

Hi, they seem to be working fine for me. Any one else having problems?
B
43
S
23
G
20
Posts: 735
Reputation: 12,027

Post » Fri Aug 23, 2013 3:11 pm

It works fine for me. But the only thing I can say is that algorithmic heavy process like this should be done directly in javascript with a plugin or behavior.

List tokenizing and operation like find() is probably what is slowing you.
B
71
S
30
G
25
Posts: 984
Reputation: 19,503

Post » Fri Aug 23, 2013 3:13 pm

Worked for me. Doing this kind of algorithm inside C2 will never be as fast as doing it in a plugin.
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

Post » Fri Aug 23, 2013 3:54 pm

@Ethan

Sorry.Now its working.
B
79
S
22
G
14
Posts: 389
Reputation: 12,324

Post » Fri Aug 23, 2013 6:39 pm

I made an astar capx a bit ago that was decently fast.
http://www.scirra.com/forum/a-star-algorithm_topic47626.html

Just tweaked it a bit so it would run continually or once per frame.
https://dl.dropboxusercontent.com/u/5426011/examples18/astar3.capx
All the events could be thrown into a function for ease of use if needed. Also all the actions that change the nodes frame and opacity could be removed since they only provide for visualization.

The one thing that comes to mind to make it quicker would be to use an array for node lookup to eliminate overlap checks.

I neglected to provide for the case of not being able to find a path, so you may need to add that. Hint: it's when the open set is empty.
B
92
S
32
G
109
Posts: 5,294
Reputation: 70,999

Post » Fri Aug 23, 2013 6:58 pm

@R0J0hound, thanks i'll take a look.
B
43
S
23
G
20
Posts: 735
Reputation: 12,027


Return to How do I....?

Who is online

Users browsing this forum: dop2000, Yahoo [Bot] and 47 guests