Steering Behaviors
When starting with AI programming, a lot of people fight with a problem
called "pathfinding": the search of the path to move from one point to
another. Pathfinding has a lot of resources around the web, mostly
related to Dijkstra algorithm or A*. While efective pathfinding
(dynamic environments, multiple agents,...) is much more than A*, A* is
a great point to start solving this problem.
But other problems
people find when they have implemented A* are: how do I move from A to
B? How do I avoid another unit that is moving while moving myself? One
way of moving the entities is using "steering behaviors": they are easy
to understand, easy to implement and fast to calculate.
The original paper about steering behaviors comes from Craig Reynolds and can be found here:
http://www.red3d.com/cwr/steer/I
like specially the Java Applets, as seing things visually helps a lot
to understand them. His paper is also not to hard on the technical
side, so it´s quite easy to follow. Some other links in his web are
also useful, as the OpenSteer project: their sourcecode can help to
understand some problems and concepts in the implementation.
To
implement steering behaviors in Jade, I first used the material
presented in "Programming Game AI by Example", from Mat Buckland
(excellent book, don´t miss it if you like AI programming). After some
tests, while most behaviors were working pretty nicely, I had several
problems, so I moved to look at Reynolds paper and other sources to
find the mistakes I was doing.
After some hard work last week,
while not all the behaviors are yet implemented, I think I have ended
with a very easy to use architecture to move entities using steering
behaviors. Also, I started to try another feature I wanted to develop,
but I never found time to: visual AI debuggers.
Debugging AI is
pretty hard, you just can´t follow code or print things on a file most
times, but watching visually what´s happening makes things very easy to
understand and fix. I added a new namespace (JadEngine.AI.Utilities)
that allows to draw easily some "2D" figures (circles, crosses,...) to
give visual clues of what is happening: it´s like Jade copy of those
nice Java Applets from Reynolds. I´m pretty happy with the results so
far, although I have to find a good way to put 3D text yet (I asked
Haddd about this subject and it seems I have missed some methods and
classes used for this, I´ll look better next time).
All the new
source code is up and checked in Codeplex. Now I´ll move on to 2
different things: adding the tutorials to the TSS (including a new
tutorial for steering behaviors) and adding the community contributions
to Jade source code.
And after that, who knows, probably more steering behaviors, but not sure yet ;)