Hey all, I've written a few games 3D with the most basic AI (enemies that head straight toward you), and had no trouble (yay vector math )
Now I'm interested in writing a real-time strategy game, similar to starcraft and command and conquer. I am confident in coding good macro AI (build orders, unit production, etc), but I am curious as to the best way for movement is. In a game, you select a unit (hehe gluUnProject ftw) then tell it to move/attack a certain location. What is the best way to do this? Here are my thoughts, any input is appreciated:
1. Check the line between pos and dest for obstructions
2. Flood-fill the obstruction to get all the coords of the obstructing object
3. Move pos around the end of obstruction that will result in the least distance travelled
4. Store this position in a waypoint array
5. Rinse and repeat until pos is as close to dest as possible
6. Move pos to each point in the waypoint array
I'm thinking that it should test ~10 different routes and determine which one's the fastest;
vector<vector<waypoint>> routes;
float minDistance=10000;int minIndex=-1;
for(i=0;i<routes.size;i++)
{
if(distance(routes.at(i))<minDistance)
{
minDistance = distance(routes.at(i));
minIndex=i;
}
}
etc.
Any ideas or links to tutorials on this subject are greatly appreciated
Beginning AI Programming
Uh... or A* pathfinding?
Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play
"Reducing the world to mathematical equations!"
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement