View Full Version : #7: Artificial Intelligence
mikedsc
08-27-2003, 12:13 AM
Do you happen to have any idea exactly how the AI gets "build orders, resource management, (counter-)attack generation, defensive mobilization"?
I'm unfamiliar with RTS design, but I'd imagine some things are hardcoded and other things are done after checking certain pre-conditions and still others are done by actual trigger-response patterns. (Then again, I'm also unfamiliar with AI design, though I have inklings...)
Corpheous
08-27-2003, 07:26 AM
In most RTS type games (ala Starcraft), the computer cheats and looks at what you have to try and defend or mount a counter-offensive to whatever you have. The computer can also predict what you have and what moves you will try to make based upon thousands of possible moves and figures out which ones you'll try to make based on which ones are most effective. The computer does all this at lightning speed which is why you usually find yourself face down in the dirt if you try to fight 8 computer players in Starcraft.
Just look at the way a computer plays chess in a video game, it goes through the same type of descisions in an RTS and maybe eventually a RPG.
Johnarras
08-30-2003, 06:32 PM
Originally posted by mikedsc
Do you happen to have any idea exactly how the AI gets "build orders, resource management, (counter-)attack generation, defensive mobilization"?
I don't know how RTSes do it, but when I implemented this in my game I did the following:
* objects called "societies" that control and aggregate knowledge about 100-200 monsters. There are maybe 100-200 societies total.
* The monsters in the society each have specific jobs that they are given by the society when they're created and grow up based on what the society needs.
* Individual monsters have several types of stimuli they deal with. At the lowest level, if they're fighting, they try to fight as well as they can, or try to flee if they're not warriors or they're getting beat up. Above, that, if they're not getting attacked and they're in the middle of some activity, they continue ot do it. Examples include workers gathering resources, builders trying to repair or build the city, and warriors patrolling or moving to guard a gate.
* Then, above that level, there are certain other stimuli that can come into play. For example, if many society members are dying quickly, the society will decide to send several warriors to kill whatever's killing the society members. If the society gets big enough, it may send 1/3-1/2 of its members to a nearby area to start a new society. If it has a lot of warriors, it may try to attack someone nearby. It may even be drawn into battle by its alignment if the alignment wants several societies to attack an enemy at one time. And, if a society is down to its last few members, it may pick a random open location in the world and send everyone to that new location to try to escape destruction.
That's one implementation, but I think the main ideas that make it work are the following:
* Make each mob prioritize its actions so it it doesn't keep trying to chop wood when it's being attacked and so forth.
* Have several layers of grouping os mobs that interact and let these various groupings both aggregate knowledge about the layers below them, and let their data be aggregated and used by the layers above them. For example, mobs are aggregated by societies, and societies use mobs to do things. Alignments aggregate data about societies, and use societies to do things. Having some layers makes for more complex interactions I think.
vBulletin® v3.7.1, Copyright ©2000-2008, Jelsoft Enterprises Ltd.