Join for FREE | Take the Tour Lost Password?
[x]

deviantART

 

Autonomous Steering - Seek by @summaro:iconsummaro:


Creative Commons License
Some rights reserved. This work is licensed under a
Creative Commons Attribution 3.0 License.
:iconsummaro:

Artist's Comments

Autonomous seeking and fleeing.

The two bots start at identical positions with identical velocities, and the target is always in the middle of the stage.
The seeker bot alters it's velocity to head towards the target, the fleeing bot away from the target.
Bots implement rudimentary inertia and torque.

The demonstration will reset itself when the seeker hits the target. Behaviors are modular and can be added to any bot with no specialized code modifications.

Steering algorithms outlined and adapted from [link]

Raw code dump can be found at [link] . Designed to be compiled using the mxmlc compiler, though you could easily integrate it into your .fla files. One day I'll write up a tutorial.

Critiques


Thank you for your Critique

You are not logged in.

Comments


love 0 0 joy 0 0 wow 0 0 mad 0 0 sad 0 0 fear 0 0 neutral 0 0
:iconthecheshirecatalyst:
Don't write up tutorials on helping people use flash. It encourages so many horrible horrible things, too many to even list. Long live mxmlc.

--
Courtesy of The Cheshire Catalyst
:iconsummaro:
Thanks for the constructive feedback.

--
In order to understand recursion, you must first understand recursion.
:iconthecheshirecatalyst:
Well i hope it didn't come out wrong, i'm sick of people posting an fla as source. Since it isn't really, i'm better off decompiling the swf and extracting the code that is in there, since i don't use the "Flash ide" an fla is worthless to me. Even though i already have my own steering code, thanks for posting actual code.

On the constructive side, i would drop the movieclip as your base class, and use sprite or the likes, as really unless it is literally something that needs a timeline, there is no need for a movie clip. And i do believe that it's much more forward thinking in your own code base to use the actual point class in flash.geom as opposed to an array, as they already have cool methods for adding it to other points, polarcoords and such. Also, i never wrote much as2, but i see some "bad" habits left over from as2, or from looking at too much of it.....but that's just nit picky, anyway, good job, i appreciate someone contributing to the whole flash community something that is actually useful, and intended for mxmlc. Good job.

--
Courtesy of The Cheshire Catalyst
:iconsummaro:
Ah, I understand now. :slow:

The movieclip/sprite thing I use interchangeably. I've yet to see a convincing argument why it matters, though I haven't specifically looked for performance/file size differences.

As for the point vs. array, I think I used arrays because they're passed by reference as default, which lets me make some short cuts by manipulating the array direct instead of passing objects around. Having said that, I haven't looked much into the point class.

I'm curious what you think are "bad" habits from AS 2? Because I didn't work much with AS 2 (though a little) but I do extensive Javascript work.

Also, could you perhaps take a look at the pursuit code (the other deviation) and let me know why it's not detecting the collision accurately and consistently, even though I'm very optimistic about the detection?

--
In order to understand recursion, you must first understand recursion.
:iconthecheshirecatalyst:
IN response to sprite vs movieclip, things that are a dynamic class like movieclip are not as efficient by a long shot, where as sprite is a static class. Eg. MovieClips you can just tack all kinds of stuff into it regardless, where as if i had var mySprite:Sprite = new sprite() I can't go mySprite.somenewproperty = something

with moieclip you have the oberhead of a time line, plus the dynamic nature of the class, it makes for quick but dirty and potentially very inefficient flashvm bytecode.

As far as bad habits that is kind of what i'm talking about, and as you informed me, that probably comes from javascript, which is very similar in nature as per ecma. as3 can be dynamic, but you should program in that way very sparingly, sticking to static predefined classes or extend said static classes.

I'll look at that code here in a minute, and let you know about it.

--
Courtesy of The Cheshire Catalyst
:iconsummaro:
Could you show me documentation or a demo where you can just "tack all kinds of stuff into" a MovieClip?

Also, you didn't give me any specific examples of what is a bad habit, which is actually what I want to know, like a line number and a file name.

--
In order to understand recursion, you must first understand recursion.
:iconthecheshirecatalyst:
I'll point it all out after i'm done with my real work for the day. as far as example code, just go look at livedocs as3 reference Sprite is just public class sprite, movieclip is public dynamic class MovieClip......then read about the dynamic property

or if deviantart doesn't break it

package {
import flash.display.MovieClip;
import flash.display.Sprite;

public class PropertyDemo extends Sprite
{
public function PropertyDemo()
{
var myMovieClip:MovieClip = new MovieClip();
myMovieClip.something = "oh look";
myMovieClip.traceSomething = function():void{
trace(this.something);
};
myMovieClip.traceSomething();
var mySprite:Sprite = new Sprite();
mySprite.something = "comment out this line to remove error";


}
}
}

--
Courtesy of The Cheshire Catalyst
:iconsummaro:
Ah, ok, I understand. Thanks for that. :)

--
In order to understand recursion, you must first understand recursion.
:iconthecheshirecatalyst:
also think about getting this [link]

it's form adobe and instead of using the mx.util class for objects and casting the array, just import com.adobe.utils.ArrayUtil; and use ArrayUtil.copyArray
so it looks like this
initEvade(ArrayUtil.copyArray(startPos), ArrayUtil.copyArray(startVel));

instead of

initEvade(ObjectUtil.copy(startPos) as Array, ObjectUtil.copy(startVel) as Array);

Plus it's a more efficient method :)

--
Courtesy of The Cheshire Catalyst

Details

December 29, 2008
16.0 KB
2.9 KB
306×258

Statistics

10
3 [who?]
491 (0 today)
10 (0 today)

Site Map