# A\* implementation in Flash

**URL:** <https://forum.kirupa.com/t/a-implementation-in-flash/185011>\
**Category:** open source\
**Created:** [April 10, 2006, 8:50am UTC](https://forum.kirupa.com/t/a-implementation-in-flash/185011 "2006-04-10T08:50:27Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dauntless](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/dauntless/32/749_2.png) [@Dauntless](https://forum.kirupa.com/u/Dauntless)\
**Post date:** [April 10, 2006, 8:50am UTC](https://forum.kirupa.com/t/a-implementation-in-flash/185011/1 "2006-04-10T08:50:27Z")

</div>

Hi,

I posted an A\* implementation a while ago. Since then, I’ve been adding features and making him faster. I now have version 1.10 ready to be published.

A\* is a pathfinding engine. It searches the fastest route between 2 given points, in a Tile Based map. If that’s confusing to you, imagine a game like Zelda. In Zelda, you play a character named Link. Link has to save the princes (Zelda) and encounters many enemies a long the way. Well, this engine could (!) tell the enemies how to behave when they see Link. The enemies should have a descent way to get to Link, so that they can attack him. But how can the enemies find their way to link? That is done by using a PathFinding engine.  
Another example is habbo ([http://www.habbohotel.com/habbo/en/](http://www.habbohotel.com/habbo/en/)) . If you click somewhere on the map, your character will move there. This is also done by a pathfinding engine.  
I’ve chosen A\* because it supports a wide range of features. You can give costs to tiles, you can make them walkable or not, you can chose to use clipping (going diagonal) / no-clipping / semi clipping, you can set a different move cost to go diagonal, etc …

You can find all the info at my blog: [www.dauntless.be](http://www.dauntless.be)

How to use it:  
[http://dauntless.be/blog/?p=38](http://dauntless.be/blog/?p=38)

How to install the component:  
[http://dauntless.be/blog/?p=33](http://dauntless.be/blog/?p=33)

What A\* is about:  
[http://dauntless.be/blog/?p=22](http://dauntless.be/blog/?p=22)

The source:  
[http://dauntless.be/blog/?p=50](http://dauntless.be/blog/?p=50)

My experience with showing AS-projects is that you only get some comments if it’s provided with at least 1 well-designd example. Therefore, I put one here:  
[http://dauntless.be/blog/?p=30](http://dauntless.be/blog/?p=30)

Also, last time, Tonypa ([flashkit.com](http://flashkit.com)) told me that Zehn’s implementation was way faster then mine. Ofcourse, it wouldn’t be smart of me to just ignore the competition. Therefore, I made a little comparison:  
[http://dauntless.be/blog/?p=44](http://dauntless.be/blog/?p=44)

Please post all your criticism here or on my blog :).

(I’ve chosen for a blog to put all my AS files on, 'cause it lets me keep all the files in 1 place and you guys could now where to find updates).

If anything is unclear, please tell me! 🙂

Attached si a little demo file. (You do have to have the classes installed to be able to use it, or add the component to the .fla file)

---

<div class="post-metadata">

**Author:** ![LunaSolar](https://avatars.discourse-cdn.com/v4/letter/l/a4c791/32.png) [@LunaSolar](https://forum.kirupa.com/u/LunaSolar)\
**Post date:** [April 10, 2006, 7:38pm UTC](https://forum.kirupa.com/t/a-implementation-in-flash/185011/2 "2006-04-10T19:38:05Z")

</div>

Check out the big brain on Brett!

---

<div class="post-metadata">

**Author:** ![Dauntless](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/dauntless/32/749_2.png) [@Dauntless](https://forum.kirupa.com/u/Dauntless)\
**Post date:** [April 10, 2006, 7:39pm UTC](https://forum.kirupa.com/t/a-implementation-in-flash/185011/3 "2006-04-10T19:39:06Z")

</div>

Uhm… ?

---

<div class="post-metadata">

**Author:** ![lunatic](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@lunatic](https://forum.kirupa.com/u/lunatic)\
**Post date:** [April 10, 2006, 7:47pm UTC](https://forum.kirupa.com/t/a-implementation-in-flash/185011/4 "2006-04-10T19:47:02Z")

</div>

I know you have everything posted in those links but a brief 2 sentence explanation of what you’ve built / what it does will probably generate more interest / response than posting links to your blog. 🙂

---

<div class="post-metadata">

**Author:** ![Dauntless](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/dauntless/32/749_2.png) [@Dauntless](https://forum.kirupa.com/u/Dauntless)\
**Post date:** [April 10, 2006, 8:14pm UTC](https://forum.kirupa.com/t/a-implementation-in-flash/185011/5 "2006-04-10T20:14:36Z")

</div>

I’ve edited my first post with a quote from my blog 😉 :p.

---

<div class="post-metadata">

**Author:** ![Dauntless](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/dauntless/32/749_2.png) [@Dauntless](https://forum.kirupa.com/u/Dauntless)\
**Post date:** [April 13, 2006, 11:01pm UTC](https://forum.kirupa.com/t/a-implementation-in-flash/185011/6 "2006-04-13T23:01:44Z")

</div>

No one else has some comments?

---

<div class="post-metadata">

**Author:** ![Joppe](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@Joppe](https://forum.kirupa.com/u/Joppe)\
**Post date:** [April 13, 2006, 11:36pm UTC](https://forum.kirupa.com/t/a-implementation-in-flash/185011/7 "2006-04-13T23:36:52Z")

</div>

Its really nice

---

<div class="post-metadata">

**Author:** ![Dauntless](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/dauntless/32/749_2.png) [@Dauntless](https://forum.kirupa.com/u/Dauntless)\
**Post date:** [April 15, 2006, 9:11am UTC](https://forum.kirupa.com/t/a-implementation-in-flash/185011/8 "2006-04-15T09:11:34Z")

</div>

Has anyone actually tried it out?

And i’ve put the source files online! (Also on my blog).

---

<div class="post-metadata">

**Author:** ![bombsledder](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@bombsledder](https://forum.kirupa.com/u/bombsledder)\
**Post date:** [April 15, 2006, 12:22pm UTC](https://forum.kirupa.com/t/a-implementation-in-flash/185011/9 "2006-04-15T12:22:53Z")

</div>

soo, im confused lol, ok your comparing yours to zehns and showing how slow yours is compared to zehns, i would rather use zehn’s now =(

---

<div class="post-metadata">

**Author:** ![Dauntless](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/dauntless/32/749_2.png) [@Dauntless](https://forum.kirupa.com/u/Dauntless)\
**Post date:** [April 15, 2006, 2:40pm UTC](https://forum.kirupa.com/t/a-implementation-in-flash/185011/10 "2006-04-15T14:40:03Z")

</div>

Yep, I have to admit that Zehn’s implementation is faster on short, easy paths.

---

<div class="post-metadata">

**Author:** ![Templarian](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/templarian/32/7152_2.png) [@Templarian](https://forum.kirupa.com/u/Templarian)\
**Post date:** [April 15, 2006, 3:53pm UTC](https://forum.kirupa.com/t/a-implementation-in-flash/185011/11 "2006-04-15T15:53:23Z")

</div>

You really kicked his \*\*\* there lol, and not just by a little by a ton. I think zehns was made for tiled based games where the viewable area is only 12x12 tiles or so.

---

<div class="post-metadata">

**Author:** ![bombsledder](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@bombsledder](https://forum.kirupa.com/u/bombsledder)\
**Post date:** [April 15, 2006, 5:20pm UTC](https://forum.kirupa.com/t/a-implementation-in-flash/185011/12 "2006-04-15T17:20:40Z")

</div>

but zhens is still super fast

---

<div class="post-metadata">

**Author:** ![Dauntless](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/dauntless/32/749_2.png) [@Dauntless](https://forum.kirupa.com/u/Dauntless)\
**Post date:** [April 15, 2006, 5:53pm UTC](https://forum.kirupa.com/t/a-implementation-in-flash/185011/13 "2006-04-15T17:53:02Z")

</div>

True.

-ActionScript 1.0 is faster than AS 2.0  
-It has less functionality  
-Zehn’s a less dynamical (since its AS 1.0)

And some other things… But it’s really up to wat you need it for.

---

<div class="post-metadata">

**Author:** ![MichaelxxOA](https://avatars.discourse-cdn.com/v4/letter/m/9dc877/32.png) [@MichaelxxOA](https://forum.kirupa.com/u/MichaelxxOA)\
**Post date:** [April 15, 2006, 5:57pm UTC](https://forum.kirupa.com/t/a-implementation-in-flash/185011/14 "2006-04-15T17:57:54Z")

</div>

I like this, and I see how yours is a benefit.

Why don’t you do comaprisons of the distance between the two points, then choose which A\* implementation to use.

And a note, Actionscript 1.0 is in no way faster than Actionscript 2.0. They are both compiled down to the same bytecode, there is no performance gain during execution time… performance gains are only made during development.

TakeCare.  
\_Michael

---

<div class="post-metadata">

**Author:** ![Dauntless](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/dauntless/32/749_2.png) [@Dauntless](https://forum.kirupa.com/u/Dauntless)\
**Post date:** [April 15, 2006, 6:12pm UTC](https://forum.kirupa.com/t/a-implementation-in-flash/185011/15 "2006-04-15T18:12:03Z")

</div>

I know AS 2.0 is converted to AS 1.0 during compilation, but still…  
I read somewhere that AS 2.0 was slower than AS 1.0 but I can’t find it. I’ll keep looking though ! 😉

---

<div class="post-metadata">

**Author:** ![bootiteq](https://avatars.discourse-cdn.com/v4/letter/b/eb9ed0/32.png) [@bootiteq](https://forum.kirupa.com/u/bootiteq)\
**Post date:** [April 15, 2006, 6:20pm UTC](https://forum.kirupa.com/t/a-implementation-in-flash/185011/16 "2006-04-15T18:20:54Z")

</div>

Nice work Dauntless!  
A\* is probably the most complicated thingamy around.

EDIT: if zhens is faster it probably has a smaller hieristic (cant remember the spelling)

---

<div class="post-metadata">

**Author:** ![vini](https://avatars.discourse-cdn.com/v4/letter/v/c77e96/32.png) [@vini](https://forum.kirupa.com/u/vini)\
**Post date:** [April 24, 2006, 4:41am UTC](https://forum.kirupa.com/t/a-implementation-in-flash/185011/17 "2006-04-24T04:41:33Z")

</div>

Well Daunt, I think you have taken the challenge pretty far and fair. Keep up the good work.
