🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

How is AI done in Real-time Strategy Games??

Started by
5 comments, last by GameDev.net 24 years, 8 months ago
Hello!

Im writting this message not to answer your question (aw!), but actually say Ive thought a lot about the AI on those kinds of game... Ack, it must be very complex =]
The right time of building could be done, maybe, by pre-creating a building sequence, or some lists of building sequences (one for a kind of terrain, one for when you are near a lot of resources, one for when resources are bad, etc)... Well, this would be very crappy, but a start... eheheh
To make computer attack you could keep checking for the number of units the player has (cheat! heeh), and quality, and when you are far superior, turn on a flag "ATTACK_NOW=1" and every, say, 5s every unit checks for this flag and move towards (with yer damn kewl pathfind ;P) the player base...heeh
Well, this is a lot crappy, but.. uh, you could start this way and keep tuning it =]

Cya,
-RoTTer

Advertisement
The way a see it... it seems to be a neural net. In a nutshell, what you do is you build neurons. Each neuron has sensor(s) and a trigger. The trigger is fired when the sensors are overloaded (you can connect many sensors to it, but each sensor has a weight which tells the nueron what's important and what's not).

Anyhow... once the trigger is fired, any neruon connected to it also recieves a signal (through the sensor(s)). The idea is, your enemy might have a neuron that does building. That neuron senses that it has very few units, so it triggers. Then you might have another three neurons connected to it, each of which control the building of planes, tanks, and men. And those neurons sense that there are too few planes, tanks, men, etc. and thus start building.

See?

For building the net (just a web) you could just use a sort of modified tree. Only, instead of a tree branching off into two, you have it hold a linked list of all the nuerons that are connected to it, etc.

I'm sure there's a better way... this is just what I think. I haven't had enough time to dwelve heavily into ai yet

Jonathan Makqueasy gamesgate 88[email=jon.mak@utoronto.ca]email[/email]
I'm thinking about this problem at the moment, too, because I've got to do some kind of rts-AI, too.

I created an editor in which the map file is loaded and set hotspots for the AI there. For example, they have a base, so their main point to defend is the base. If there are some other strategically important places, they get spotted, too.

All the units have different attitudes, some cyborgs run away when meeting an enemy tank, some call for help, ... It's nothing more than a big collection of "if"'s and units attitudes. Make the units look intelligent is really hard to do, not all tanks may act in the same way, there should be some differences and, a main point, they may not be perfect. Creating perfect enemy units is really easy, but let them acting human is much harder to do.

So, the AI knows how to build up a base and what it needs, sometimes, it does an strategical mistake, sometimes it does not. Then it has a number of how many units of this type it needs and how many of another type to defend the base. After having built a good defensive line, the AI begins to build attacking units, ...

An AI is normally built up like this, it sounds easy, but it's hard to implement. And this is the point where most of the RTS-games suck, most of them have good game ideas and nice graphics, but only few of them have a good AI that makes the game fun to play.

Also you have to decide whether the AI is cheating or not. If it's cheating, it's easier for you, because you can give the AI the information where the players base is and it gets information about the terrain, so it will directly move to your base if it attacks. If not, there are much more decisions needed (and much more functions to implement).

CU

------------------
Skullpture Entertainment
#40842461

Graphix Coding @Skullpture Entertainmenthttp://www.skullpture.de
You know, it seems like AI is a pretty difficult problem. The complexity in representing the problem and implmentating the soulution are just a few of the reasons. So, to that end i suggest striving for simplicity in both. In representing the problem, state your problem as simply and clerly as possible. For instancte in the case of a RTS:

problem:
-How can we create coordinated effective behaviour of units within a realtime tactical combat game?

solution:
-To achive our goals for coordinated unit behaviour we use a hiearchical control structure. Where each node within the hiearchy tree parses a command as it best able into subcommands and so on. To gain realtime responsiveness we imbed out units with simple controller fucntions providing base actions. Such as attack when close to enemy, run when hurt badly, etc.. These contorller function are within the scheme of reflex actions and can surpress or express other reflex actions but in themselves dont form partically intelligent behaviour. To merge the actions of the reflex and command driven, we have to create an interface class which can map on into the other. The combination of the heiarchcial comamnds and the reflex actions should fullfill our requirements of intelligent coordination effective behavior of real time units.

From this we then proceed to formalize the problem and solutuion in a code framework which would give us the best chance of success, we also strive for simplicity. The scope of implementation is beyond my experience and this reply however 8^). Hope this helps, ya!

-ddn

Check out the book Real Time Strategy Game Programming w/ DirectX. It has a good bit of imformation on AI. The guy who wrote it worked on Age of Empires. It also has info on pathfinding.

Former Microsoft XNA and Xbox MVP | Check out my blog for random ramblings on game development

Hey, I'm making a real-time strategy game like Command and Conquer in directx. I've got the tile engine working, the units are handled in a linked-list and work fine, and the pathfinding is pretty much shit right now but is getting better.
My question is how do I do the AI in my game? How do I know where to tell the AI to build building and in a specific location, and attack, and stuff like that?

Is there anywhere where I can get a tutorial or examples on this or anything too?

Please Help,

email - datisme@notme.com

Thanks alot,
Da_KiD

I also believe that the front page of this site has a tutorial on AI for beginners, it may be worth checking out.
I have my own opinion on how to do it but I've never programmed AI for strategy before (I have for other games) so it's only conjecture.

This topic is closed to new replies.

Advertisement