Advertisement

An idea on RTS Game AI

Started by January 26, 2002 12:32 AM
11 comments, last by techpage 22 years, 10 months ago
Hi guys, i have an idea on RTS games AI. I got the impression that people often interpret falsely the complexity of a good AI in RTS games. So I would like to discuss this with you guys. What I have in mind is, we break up the complexity into "unit-level AI" and "player-level AI". Unit-level AI handles most units behavior like group management, pathfinding, alert system, etc. while Player-level AI handles the way it should act as in a player-level against human player. Unit-level AI is already tackled mostly so the big issue here is the player-level AI. This is where the tactical and strategical AI are played in. Last time, i brought up into a session, the issue of "cheating AI" and "honest AI". So, if let''s say, we''d want to eliminate cheating AI to produce more realistic AI in RTS, we should implement fully honest AI. It might be easier to implement it in player-level AI. My idea is, we inject actions that are not found in most RTS games like scouting, patrolling, spying, etc. Additionally, we emulate the behavior of a human player. For example, human player can go to places by clicking it on the minimap or by dragging the battlescene to desired places. This action could be emulated to give balance into the game. Well guys, i''m not much a brainer so I might be wrong... totally wrong. But i really need you guys'' opinions and suggestions. So what do you think? Thank you in advance
Actually, Starcraft has a system of AI sort of similar to that.

Basically its three parts.
1st level, is unit AI, movement, attacking, patrolling. The really basic stuff

2nd Level, is what to build, this is provided by aiscript.bin files which just contain a sequence of buildings and units, as well as when to attack.

3rd Level, is the AI that does tactics (although its limited). This controls building placement, unit deployment, and all the other tactical stuff.

As for getting a cpu to emulate a persons behavior on the other end... my question is why? If I could play starcraft via some kind of neural link that would let me bypass having to use the gui completely, I would so take it. If you want the cpu to seem more human (in a speed sense) just add some thought delay.
Advertisement
What I plan on doing for my RTS is a 3 layered type thing:

Player level
Group level
Unit level

The unit level ai really isn''t much (just pathfinding really)

Group level will coordinate groups of units, they don''t need to be close to each other, so a group of units could be guarding the base while being spread out. Groups will also be used to attack the player, a group can also just be 1 unit.

The player level AI controls the groups - telling units to join groups if they don''t have them, telling groups to defend/attack and also coordinating attacks (so two groups can effectively attack the player without having to know of each other)

Trying is the first step towards failure.
Trying is the first step towards failure.
quote: Original post by Tricron2
As for getting a cpu to emulate a persons behavior on the other end... my question is why? If I could play starcraft via some kind of neural link that would let me bypass having to use the gui completely, I would so take it. If you want the cpu to seem more human (in a speed sense) just add some thought delay.


I agree with you IF there is some kind of device that link our brain with the game system. So I guess, for this time, playing RTS is still meaning to use the GUI completely. Well, I spoke of "cheating AI" and "honest AI", so according to people in another session:

Cheating AI uses confidential information to give advantage to computer AI over the human player. This could be giving more unit strength, world map revelation, unlimited resources, infinite fog of war.

Honest AI doesn''t use this. So by eliminating cheating AI and fully using honest AI would mean introducing new actions. But what actions? So I thought adding delays wouldn''t be "honest", would it?

By the way, would you visit...
http://www.gamedev.net/community/forums/topic.asp?topic_id=72850

it''s a whole session on "honest" and "cheating" AI, so if I were to eliminate cheating AI and fully use honest AI instead, what should I do to my RTS game?
If the game looks like it''s behaving intelligently, and isn''t impossibly hard, or ridculously stupid, then what does it matter how the underlying effects are programmed, be it with extremely complicated Neural Nets emulating the processes in the brain, or some cleverly developed scripting.

I agree, that RTS games are in dire need of showing a little more intelligence in the overall ''master control''. The last RTS game I played was Cossacks - European Wars, and I was appalled at the level of AI, which wasn''t much better than the original C&C. Although it was possible to arrange your men into formations of given size, and to have vast armies up to 4000 men at once on the map I think, however the computer never made use of it, neither did it make use of the advantage of high ground in fighting. HOW PANTS!!!

I agree, that simple behaviours could be developed for scouting / skirmishes / ambushes etc. If I were to develop something like this, I would implement it into the map data structure (If I were doing it in Isometric). As the computer AI uncovered areas of the map, it would log the terrain type, gradient etc. Then assess aspects such as cover from trees, possible attack points, and the strong defending points, and then assign weights to certain areas of the map for given tasks(to be stored within the map data structure). The AI would then need to set up a queue of tasks, based on Priority to generate units / buildings etc. This can be based on the strategy it is taking at that point in the game, i.e. Defending a position, attacking a position, advancing, retreating etc. Scouting would use a certain combination of characters, i.e. fast riders, accompanied by some infantry for support or similar. But using a technique such as Fuzzy logic, we could adjust the combination of troops in the squad according to the area they were scouting.

Every time a computer character dies, maybe it should ''try and assess'' what happened, what height was it at, at what height was the enemy, was it under cover, was the enemy in cover, what type was it, what type was the enemy, was it in a group / team (if so, how big). This is all valuable information that we take in and use in future, although the AI doesn''t maybe each death should be marked on the map, therefore a place with a high amount of deaths should be scouted etc.

One thing that really annoyed me about Cossacks was that the AI never considers the type of units it is fighting against, and would always send a column of pikemen against artillery based on a hill with riflemen support. For a start, the column is for movement along roads etc, it gets smashed by artillery. Is it just me or does that sound like such an easy thing to program? Obviously, the AI has commands that it gives to its characters such as Attack, Move, Defend etc. Just modify the script that issues the command to attack, and have some underlying battelield warefare knowledge implemented.

Anyway, if anyone has got to the end of this message without falling asleep then well done, and I hope that we get some interesting responses.

Well lets plan out a theoretically ''good'' AI for a made up strategy game.

Well center it around some really simple concepts.
1 - there are three units. Ents, Rockmen, and Swords men. (paper, rock, and scissors =)
2- The means to produce more units is closly tied to key points in the map. We will assume these points are limited, and that stockpiling resources is not allowed.
3- A player builds the unit production buildings of which there are 3 (one for each unit) and a forth (free) building that gathers resources.

Now we will implement the "unit-level AI" and "player-level AI".
As for unit level, its been fully researched by all those other RTS. Now we must figure out what to do for player-level AI.

Given those conditions... whats your primary objective? I would say kill the enemy.
Now whats secondary? Defending yourself? Aquiring Resources? Or Exploring the map?

It depends on the situation... therefore I think the first thing we need to do is to set up a fsm (finite state machine) to start handling out different objectives.

I''m tired of talking (/typing) so sombody else can figure out what else we need to to.
Advertisement
Ok Tricron,

That sounds like a good start, FSM''s can give us a good goal based architechture to the AI. Although in terms of team AI, maybe a more ''loose'' technique may be needed. Furthermore, it may be difficult to run certain tasks in parrallel if we use an FSM, i.e. we can create new units, gather resources and Build stuff. But we don''t want to do them in that order, the beauty of the RTS ''paradigm'' is that all of these can be done simultaneously. I think that the FSM is the ideal construct for a unit level AI, maybe if the unit is ''idling'' i.e not recieving commands from higher level AI it could enter FSM mode or something.

Maybe a good solution to this is to use a goal-based architecture as we said before and to develop something maybe called a ''parrallel state machine'', where each state is assigned triggers as inputs (things that must occur to enter that state), and resulting command outputs (that are passed down the hierarchy to the unit-level AI''s). But instead of locking the AI into one state at a time, multiple states are accessible simultaneously.

So the ''gather resources'' state may have a simple Economics engine that calculates what units are required for particular strategies, and develops a set of resource requirements based on that. Therefore we have:


INPUTS STATE OUTPUTS
Economics Engine -> Gather Resources -> Unit move, unit harvest etc...

If we allowed some interconnectivity between states, the Economics Engine would ''log a message in the command queue'' of the ''Unit Building'' State requesting more peasants / harvesters whatever.

The goal based engine will work as you said Tricron, and at the highest level we have to win the mission. Subsidiary to that, we have to build units, harvest resources, develop a strategy and form military teams / groups. I''m not sure how we could handle the priorities of each of these tasks, but they certainly interlink as I mentioned before. The situation would change in the duration of the mission. There is a start (Build essential buildings / units), a middle (Scout, Develop a strategy and prepare specific units for that strategy), and an end (attack the enemy, and hopefully win), but this may be a recurring cycle that happens many times during one mission if the end is unsuccessful, if for example, the enemy attacks you first and you have to change strategy to defend.

I''ve gone a bit off subject, and I know we wanted to keep it simple so lets start with how we could program some simple behaviours.

Firstly the start -

Assuming we have nine units, one of each, and a resource building. Based on our own knowledge, each unit is just as susceptible to attack from any of the other two units, so we must generate each unit in equal proportions (a bit too simple), but rocks are slow and heavy, but powerful. Paper is light and fast, but weak unless in large numbers. Scissors is good at short range, but hand to hand is crap against rocks.

As the player, we need to quickly enter the middle stage of the game, so we must find the enemy and his position in order to develop a strategy. So, based on the speed of paper, we will build that first (we can use weightings for certain tasks, so for scouting, paper = 3, scissors = 2, rock = 1). Our initial strategy is that of scouting and unit production, therefore we have a need for a paper unit production building, so the economics engine passes this information onto the unit building state. The Strategy engine is set to Scout and also to defend the current position with the present nine units, therefore a message is logged to generate some scout units. The best scout units are paper, but if we want some variety to add overall structure to our scout party we could include a few scissors as they also have reasonable scout weightings.

Do people see where I''m going? I hope so, and I hope that it seems like a logical method to use to generate a solid, parallel state, flexible AI.

Cheers, tell me what u think
quote: Original post by techpage
Hi guys, i have an idea on RTS games AI. I got the impression that people often interpret falsely the complexity of a good AI in RTS games. So I would like to discuss this with you guys.

What I have in mind is, we break up the complexity into "unit-level AI" and "player-level AI". Unit-level AI handles most units behavior like group management, pathfinding, alert system, etc. while Player-level AI handles the way it should act as in a player-level against human player. Unit-level AI is already tackled mostly so the big issue here is the player-level AI. This is where the tactical and strategical AI are played in.


Well, what you''re talking about (as others have said) has slowly grown into a fairly standard way to handle the more complex AIs. I myself offered up an "Admiral/Captain" approach for Starfleet Command and I know of several other games in the RTS realm that take similar approaches. I haven''t seen it used much in FPS games yet though, mostly because they''ve got a different ''dynamic''.

quote:
Last time, i brought up into a session, the issue of "cheating AI" and "honest AI". So, if let''s say, we''d want to eliminate cheating AI to produce more realistic AI in RTS, we should implement fully honest AI. It might be easier to implement it in player-level AI. My idea is, we inject actions that are not found in most RTS games like scouting, patrolling, spying, etc. Additionally, we emulate the behavior of a human player. For example, human player can go to places by clicking it on the minimap or by dragging the battlescene to desired places. This action could be emulated to give balance into the game.


While what you''re talking about is a good idea...using the same interface for the computer opponents as for the player...it doesn''t prevent cheating. Witness the newer games (such as Starcraft for example) which still cheat like crazy.





Ferretman

ferretman@gameai.com
www.gameai.com

From the High Mountains of Colorado

Ferretman
ferretman@gameai.com
From the High Mountains of Colorado
GameAI.Com

quote: Original post by Tricron2

As for getting a cpu to emulate a persons behavior on the other end... my question is why? If I could play starcraft via some kind of neural link that would let me bypass having to use the gui completely, I would so take it. If you want the cpu to seem more human (in a speed sense) just add some thought delay.


Actually I think we''ve got enough trouble as AI developers just getting to the AIs to play a credible and challenging game without overtly cheating. Tossing in ''human like'' command delays would just make it worse at this stage, IMO...can you explain to your producer that 1/2 of your AI''s CPU time is "wasted"?




Ferretman

ferretman@gameai.com
www.gameai.com

From the High Mountains of Colorado

Ferretman
ferretman@gameai.com
From the High Mountains of Colorado
GameAI.Com

quote: Original post by Mattr
If the game looks like it''s behaving intelligently, and isn''t impossibly hard, or ridculously stupid, then what does it matter how the underlying effects are programmed, be it with extremely complicated Neural Nets emulating the processes in the brain, or some cleverly developed scripting.


Great comment Mattr! That''s exactly what I got out of Minsky''s talk at the 2001 GDC, in fact.

quote:
HOW PANTS!!!


Perhaps I show my ignorance here....but what the heck does this mean? Please help a clueless American...

quote:
I agree, that simple behaviours could be developed for scouting / skirmishes / ambushes etc. If I were to develop something like this, I would implement it into the map data structure (If I were doing it in Isometric). As the computer AI uncovered areas of the map, it would log the terrain type, gradient etc. Then assess aspects such as cover from trees, possible attack points, and the strong defending points, and then assign weights to certain areas of the map for given tasks(to be stored within the map data structure). The AI would then need to set up a queue of tasks, based on Priority to generate units / buildings etc. This can be based on the strategy it is taking at that point in the game, i.e. Defending a position, attacking a position, advancing, retreating etc. Scouting would use a certain combination of characters, i.e. fast riders, accompanied by some infantry for support or similar. But using a technique such as Fuzzy logic, we could adjust the combination of troops in the squad according to the area they were scouting.

Every time a computer character dies, maybe it should ''try and assess'' what happened, what height was it at, at what height was the enemy, was it under cover, was the enemy in cover, what type was it, what type was the enemy, was it in a group / team (if so, how big). This is all valuable information that we take in and use in future, although the AI doesn''t maybe each death should be marked on the map, therefore a place with a high amount of deaths should be scouted etc.


The problem with this is that it''s not at all easy to do that kind of map/battle analysis and still maintain a real-time game. I''ve just been editing some of the terrain analysis articles for Game Programming Gems 3 and there are some great ideas in there, but doing some of them in real-time is just plain hard . CDDNA uses genetic algorithms to do analysis in a kind of ''playbox'' but it''s all done AFTER the game is over, not during.





Ferretman

ferretman@gameai.com
www.gameai.com

From the High Mountains of Colorado

Ferretman
ferretman@gameai.com
From the High Mountains of Colorado
GameAI.Com

This topic is closed to new replies.

Advertisement