AI Ideas

DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #1
I was going to post this on gamedev.net, but I don't like the attitude over there. And I hope to find enough feedback here, too.

So here it goes: I was thinking about how the AI for an RTS game should work, and I am wondering if it is a good idea to actually do it like real military does, with a hierarchical chain of command.

I imagine units are told what to do and what to shoot by their commanders, who decide what formation the units should form, etc, and who in turn are told by their commanders what to do.

Further, each AI level can only communicate with ±1 level AI, and that each AI level only performs trivial tasks, making the code very small. Of course, not every AI has to be a real unit, but can be a virtual unit (like somebody sitting in the command center).#

If I am correct, every AI could be implemented with a minimal amount of code (and minimal errors), and they should behave like those robots who collect pieces lying around into large stacks despite not being told to do so, but only how they should react to a collision. Kind of a bottom-up system like a neural network.

Whaddaya think? Is it worth to pursue this idea, or is there some bad things I didn't think of?

- D.G
Quote this message in a reply
macboy
Unregistered
 
Post: #2
Well one of the disadvantages might be that your command gets lost somewhere along the pathway of AIs. Bored
Quote this message in a reply
Member
Posts: 201
Joined: 2002.06
Post: #3
If the AI is supposed to simulate a "god-mode" to mimic the player's abilities, then a hierarchical command structure would not be optimal. In real life, hierarchical command structures are made so that higher-level officers need not mess with lower-level problems, and vice versa. The main problem with this that doesn't exist in an RTS from the player's point of view is that the player always knows everything that is going on due to the third person perspective of the battle. If the computer is put at a disadvantage by communicating only the most basic of information to the highest level of command, problems could come about. Example, a unit from one command group is far from the other units of the same group but close to another. If a group it is near to is ordered to do something, that unit will not assist. Likewise, if its group is commanded to do something, it will attempt to cross the entire map, when it would probably not make it in time to be of any help.

If the player, however, operates on a hierarchical command structure, the AI would, of course, have to be implemented on a similar level to be fair.
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #4
Quote:Originally posted by geezusfreeek
...
If the player, however, operates on a hierarchical command structure, the AI would, of course, have to be implemented on a similar level to be fair.


I disagree. The player has the intelligence to decide on such a situation, the computer doesn't have the global intelligence to assess the situation. The player can still be given control of all units as usual. But, like with ants, if every AI goes doing his task without minding his fellows ( =same level) business, things should work out.

A situation like the one you mentioned should not even occur if the AI is done correctly. Units don't have to be statically assigned to any commander, but can be moved and re-assigned. And a unit could have the intelligence to determine that he cannot fulfill his given task, in which case it reports to the commander, who may decide to give the unit another task or in turn tell his commander that the unit is of no use for him and should be re-assigned. Units may report the need for assistance, discovery of an enemy base, and all other things to their commanders, who may react to the situation and/or pass it on to their commanders, and so on, until the information is either no longer passed to the higher level because the information was sufficiently evaluated, or it has reached the highest level.

Now, an AI does not have to ignore the other AI's, but can act on his own, as long as it conforms to its commandes, eg. patrol, defend, attack at will, etc.

Basically, the simple sub-sets of AIs should act like a player would act, but without the complexity of one hugely complicated central intelligence.

- D.G
Quote this message in a reply
Member
Posts: 201
Joined: 2002.06
Post: #5
I agree, but the key element would be in the adaptability of the units at the lowest level. Second would be what sorts of commands get issued from above. Too general and the intended purpose is lost. Too specific and the units cannot adapt to changing situations.

I think the correct way to implement this would not be in a hierarchical command structure (units being separated into different command groups), but in a high level control which is designed hierarchically by objective. What I mean is, have an AI based on objectives rather than units. Have high level objectives which give mandates for more specific objectives. The advantage to this is that no one unit is assigned to a task. There will be no limited resources.

Actually, maybe some sort of hybrid would be more appropriate.
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #6
Obviously, the high level AIs need some way to asses the strength and situation of the lower level AIs, but the lower level AIs don't need to be informed about the big picture. What commands should be issued is not easy to determine, but one may pass around general events, which contain certain types of information, and only those AIs react to it who can (eg strategist AI, supplier AI, Chief Commander AI, pass it around otherwise. A nice protocol would be nice, and shouldn't be too hard to adapt to the specific situation.

And as I said, the AI does not have to correspond to game units, but represent a layer of abstraction, but still have its own state, independent of the others.

And all AIs can communicate, directly or indirectly. And no one unit will ever be assigned to a task. Even a soldier can request assistance, or its commander may decide to order re-inforcements, or even the general may decide that a certain unit needs support. My idea is that the AIs at every level try to maintain an optimal strategy with respect to their sub-tasks, but may not completely selfishly decide to add units to their task, but must tell their commander of their need, and since he knows of a bigger picture, he may decide to relocate units, depending on where they are needed most. Depending on implementation details, the hierarchy may even be bypassed under certain circumstances.

One may not have absolute control over the abilities of the AI, as it is the sum of the different AIs skill and communication. I think, therefore I am. Also, this should give a very interesting AI personality. Imagine, you can have slave armies, where the soldiers are cowards, but the commanders are offensive and skilled, or you might have an army in which the soldiers are suicidal but the commanders rather thoughtful. Also, this system should make it easy to implement personalities for units, such as the heroes in War3, though those don't really have a personality except for their distinct skills.

- D.G
Quote this message in a reply
Member
Posts: 201
Joined: 2002.06
Post: #7
If you haven't read this yet, do it now. It seems very well thought out:

http://gamedev.net/reference/articles/article545.asp
Quote this message in a reply
Feanor
Unregistered
 
Post: #8
I believe the hidden obstacle in your plan is that you are forgetting that A.I. is stupid, while the intermediate military officers are at least functionally intelligent, whatever their strategic abilities. In your model, the player takes on the role of supreme commander. He issues orders to his generals, who issue their orders to the regimental X.O.s, and on down to the squads and units.

While you might be able to issue good orders to your generals (assuming you can find a good language in which to express them), I doubt that the generals and the rest will be able to act on those orders in such a way as to do anything useful, without vast libraries of code specialized at strategic military campaigning, intelligence gathering, and troop deployment over varied terrain.

I love the idea for the model, but the processing power required seems at first glance to be beyond the possible. Certainly it's beyond the practical.

Devil's advocacy aside, there is something to be said for spending some time here discussing what the minimal achievable implementation might look like, and what it's successes and failings would likely be.
Quote this message in a reply
Founder
Posts: 1,138
Joined: 2002.04
Post: #9
I read a paper on what you want to do some time back. It was very interesting and I think something worth trying out. How about running a simple simulation with "block graphics" (or even text) to see how it would work out?

I think a game based on what you are thinking about would be very interesting. I'm not sure if in the end, the opponent will seem "smarter" or better, but it would be interesting to see how it plays some games.

I'm wondering, at each level, would the AI learn from their mistakes, and take that into consideration for the future? Perhaps only the higher command AI. For example, if in the past it tried to gain territory to quickly without making sure the supplies lines were there to feed the front, and then lost some battle, it would know that it needs to be careful of repeating that in another battle.

It would also be interesting to see a case where the AI would in effect "sacrifice" some division/platoon, in order to win the overall battle. Would those lower-down AIs know they were cannon fodder and keep doing what they are told? Or would they say, "screw this... we surrender." Or perhaps break-order/disregard a command?

Very interesting stuff.

>intermediate military officers are at least functionally intelligent
Military Intelligence? There is a joke on that.

Good luck!

Carlos A. Camacho,
Founder
iDevGames
Quote this message in a reply
ricuse7
Unregistered
 
Post: #10
Persuasive AI?

Like not having full controll over the people and have them able to and sometimes willing to sabatage you command? But only if your a bad commander.
Hmmm sounds um interesting but that would mean implamenting a full cd's worth into just one character in the game... but with DVD games.... Hmmm I like this Piggy back this onto a world such as EverQuest (EverCrack) or perhaps even Lineage... hmmm!

Hey Sta7ic if you read this you should employ it. Fully interactive world my butt. You can't have one untill you make the non Played Characters play as having dynamic feelings for instance if someone annoyed him he would be annoyed for a little while before he would talk nicely again. Like the beasts in Black & White...

Nevermind It would take *WAY* too much time to code something like that. But it could be done...

Of course this would also take more processing power... But the people in the sales and game Dev would love it (or would they?)

But it would be one heck of an addicting game!!!
Quote this message in a reply
Sta7ic
Unregistered
 
Post: #11
I've thought about this a bit previously, and I concluded that it'd likely work best with the brighter units tacked onto the traditional RTS setup. Yes, I know tacking things on is my M.O., but it works.

There'd be three, maybe four levels of AI command: troop, squad, company, and batallion. Anyone who doesn't recognize these divisions should back out of this thread quickly. Commands and reports would get kicked around one level at a time, but the overall C3 (command, control, communication) would remain available to the player, so that a top-down/trid view is available.

At the troop level, commands are specific. Troops get up, get down, fire at targets, switch/reload weapons, chuck grenades, use flares/objects, etc. They report if they see movement or lose contacts, and if something interesting happens.

With a squad, the squad leader is getting target and situation reports from the troops. Commands are directed from the S.L. to hold fire, engage targets, advance, retreat, etc. Communications are bounced up when there are contacts, no more contacts, injuries, and kills. In the idea that I wrote down, the player would get radio reports from the squad leaders mid-game, rather than text or virtual (AI) messages.

Company and Batallion levels of command are directed by the player. Period. They recieve messages as to what's going on where, and can direct teams to secure, defend, scout, or release given areas -- which are loose enough for the squads/troops to find their own cover (or complain about a lack of it, heavy AI thing here).

At all times, the player would be able to see what's going on. You woudln't be finding out grim things that happen suddenly at bad times, because they'd've been radioed in. This is sort of a utopian Myth 2 setup, because your teammembers would actually TELL YOU what's GOING ON!!!

...uhmm... Sorry about that.

Control could be taken at any of the levels, altering the zoom and scope of the view the player is given. Orders/buttons would change according to the level as well, along with the chatter that the player heard.
All and all, the idea was interesting, but I don't have the plans or assets available to finish it...

-Sta7ic Matt
Quote this message in a reply
Feanor
Unregistered
 
Post: #12
You guys might wanna come down from the clouds a bit and consider some implementation issues. (BTW, Sta7ic, did you not forget the Platoon?)

How do you issue orders to generals, or anything above the trooper level? I guess squad could be the same as issuing the same command to all the soldiers individually, but they would take on distinct roles and work as an entity. So you'd have to define what the individual roles were. The first challenge is to have A.I. that could: decide (sensibly) what order to attack enemies in, to properly use suppressing fire, the right way to deploy mortars, and the like. (I'm thinking in terms of the fighting I saw in Band of Brothers.) And it would be really difficult to not use the by-the-book strategies when called for -- but I guess that is where the player comes in.

I have no idea how one would simulate high-level orders, but it would maybe require the player to actually draw up an attack plan which the units would then adhere to. The player would have to learn some kind of scripting system in that case, which would severely limit the game's popularity with casual gamers. You would also have to have maps in advance in such a scenario.

What kind of battlefield mechanics would you be thinking of, Dooog? Would you have maps, or would it be like Warcraft and use a fog of war? That always means every move is semi-random, and it would be impossible to equip the A.I. with detailed strategies, since everything would have to be dynamic. I don't even think the trickle down of orders would work without field intelligence.
Quote this message in a reply
Sta7ic
Unregistered
 
Post: #13
Platoon, ::shrugs:: as long as the point comes across.
My above rambling wasn't so much as where to direct the orders as it is the point from which the orders are given. The player above would have the option of the oh-so-fun Captain's Chair (SR term, don't argue) where group commands are given (a la Ghost Recon with better control and viewing positions), or the scope can go down to a squad, where orders to individuals can be given (*Crap micromanagement). Orders would be labeled as "loose" or "strict" in accordence to where the player was situated, and the AI would kick in as needed.
Going down to the trooper level kicks out the AI in favor of leading the charge. Hardcore players go label settings for "Squad command only" or "Only use this trooper", and go for a somewhat earthier experience. Alternately squad-level with a C3 map available (again, a la Ghost Recon), or teaming with order given to human squad commanders who are stuck in squad-level. Teamwork needed there.
For implimentation, the high-level position would be akin to Myth/Craft, where you select groups or individual units and get options accordingly. From a strict squad-level position, the ability to radio kicks in, and you are barred from directly seeing friendly units or their LOS, and have the option of group orders or individual orders (a point barred from the high-level position). A trooper-level player can yell to the team and sight in just like a FPS.
This would require a fairly dynamic engine, admittedly, but "careful use of VLOD could make it work" (inexperienced BSing). For the AI, direct could be substituted for bright, and the "brain" would be expanded as gameplay flaws were found (amid the programmer art and cheap pre-alpha levels). As for the meat of the game, that's for whoever's designing it.
There would be no grand scheme -- that'd take too much time, effort, and kludging to pull off.

-Sta7ic Matt
Quote this message in a reply
ricuse7
Unregistered
 
Post: #14
I'm just going out on a limb here but of course if done this way with the Myth type gameplay would you in good heart be able to say... make the troop that has been with you for 5 or six maps with minimal losses learn what your orders would be and ask you then carry them out in battle?

Cuz that would be just friggin awesome for some of us that like not having to pay attention to too many things at once when coordinating 3 attacks at once.
Quote this message in a reply
athomson
Unregistered
 
Post: #15
Quote:Originally posted by DoooG
So here it goes: I was thinking about how the AI for an RTS game should work, and I am wondering if it is a good idea to actually do it like real military does, with a hierarchical chain of command.

I imagine units are told what to do and what to shoot by their commanders, who decide what formation the units should form, etc, and who in turn are told by their commanders what to do.

OK, but you have to fit the difficult tasks (like path planning) in somewhere.

Quote:Further, each AI level can only communicate with ±1 level AI, and that each AI level only performs trivial tasks, making the code very small. Of course, not every AI has to be a real unit, but can be a virtual unit (like somebody sitting in the command center).#

See above, path planning in a dynamic environment is not an easy task.

Quote:If I am correct, every AI could be implemented with a minimal amount of code (and minimal errors),

Not in my experience (Robocup F-180 league), but then most of the teams used a two tier system (so the amount of intelligence required at each level was fairly high): A strategy planner ("The ball is over by their goal so these three robots need to be strikers, this one should hang back as a defender and the goalie can do whatever it wants") and a low level planner which handles path planning, obstical avoidance, etc. For a RTS game the lowest level (the individual unit or whatever) would have to do it's own path planning, morale checks and so on. It can be done, but it probably would not be as easy as you think (that just described almost any programming project didn't it? Smile ).

Andrew.
Quote this message in a reply
Post Reply