Jump to content
  • Advertisement
Sign in to follow this  
mavvie

Beginning AI Programming

This topic is 2439 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 :D

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!