RTS AI

Started by
23 comments, last by spencerholmes 18 years, 9 months ago
A* for RTS games:
the map should be completely visable to the A* pathfinder. Otherwise you get bizarro behavior that frustrates the user. Typically in an RTS game you can see land features through the shroud, it's only the locations of enemy troops that is shrouded. Either way, you always want the A* to be completely knowledgable of the terrain. The amount of knowledge that you give the computer opponent is a lot more debatable and depends on implementation.

Most RTS AI cheats blatently and gives the AI complete knowledge of the board state (essentially the AI always plays without a shroud). You can trick the user into thinking the AI has a shroud by dumbing down it's moves or just simply by introducing random selection into the process.


AI:
I seperate the AI into 2 basic parts:

1) Unit level AI. things like targeting, defending themselves when attacked, firing weapons, playing animations, guard states, move execution, etc.

2) tactical level AI. things like planning where to attack, where to move troops, how many troops to move to tactical targets, when to attack, when to defend, etc.

To make things easier on you in the programming, it's much easier to have the tactical level AI control troops by essentially simulating user input. That way the unit level AI doesn't need any changing to work on both player and computer controlled sides. By simulation i don't necessarily mean simulating mouse-clicks, etc, but rather just hooking into whatever code gets executed by user input.

If you are starting from scratch tackle the unit level AI long before the tactical level AI. The game should be completely playable by a human before you even start to work on the tactical AI.

-me
Advertisement
Thanks very much for your advice - I like the sound of it. I'm not sure if I'll actually have a shroud - I suppose most players will expect it but I never liked playing that way! One older game let you see the last state of the map under the shroud, including buildings but not units. Letting the AI see that would help it to know where your base is/was while hiding your exact troop strength etc.

I'm still not sure about A* though. If units only know about the explored map they will uncover more of it looking for a path which would make exploring the map early on both easier and more profitable. But as you say, providing a map of the terrain to start with would remove this problem. I remember WarcraftII frequently got units stuck up against obstacles when they got lost, but it seems such behaviour is just not acceptable anymore.

Thanks again.
This thread owns! This is how AI gets implemented in game programming, for real.

[Edited by - Pipo DeClown on July 9, 2005 2:53:32 AM]
Worse comes to worse, you can always backtrack...

Also, remember to weight squares based on the amount of enemies there... (so our scout party isn't going to run straight through the enemy camp before getting killed).

From,
Nice coder
Click here to patch the mozilla IDN exploit, or click Here then type in Network.enableidn and set its value to false. Restart the browser for the patches to work.
Quote:Original post by Pipo DeClown
This thread owns! This is how AI gets implemented in game programming, for real.
I don't get it. It sounds like sarcasm but about what? Your rating suggests much knowledge, sir - do you have anything less cryptic for this thread?

RTS AI?

Well this is pretty much how the 'professionals' do it:

void rts_game_ai(){    cheat_a_bit_before_game_starts(resources += 10000000, hugebase++);    send_multiple_weak_and_pointless_attacks();    act_like_youre_actually_gathering_resources_not_cheating_to_get_them();    cheat_some_more();    lose_building_to_enemy(OH_NOES);    cheat_more(CHEAT_INFINITE_RESOURCES | CHEAT_FAST_BUILD);    while(still_alive() == true)    {        send_multiple_weak_units_to_defend();    }    die();}
[smile]

But seriously is RTS game AI still generally poor, relying on perfect knowledge and additional resources? I'd got the impression modern games didn't do that.
What are the recent games which follow the style of warcraft2 and C&C, and how is the AI different in terms of unit AI and tactics?
Hmm, C&C Generals and Age of Mythology are the newest RTS games I own. Can't say a lot about AoM because I didn't play it a lot.


I'll make a comment on the C&C Generals AI though. This is just roughly what I can remember from playing recently.

I have heard that the Generals AI does cheat for resources and such but I can't say I've really took any notice, you generally don't when simply playing a game. I might fire up a quick skirmish and take control of all resource gathering methods to see how it goes though. I'll let you know if I actually do do this.

I haven't played any skirmishes against the AI yet, I've been playing through the campaigns on the hardest difficulty (though with 2 missions left on the 3rd campaign I'm finding it quite easy). The AI does seem to be constantly sending the same types of units in the same sized groups constantly over and over. Every now and again it might just send in a couple different units but again these are the same every time (usually "artillery" style units, long range units meant for taking out structures).

So lets take a look at an example scenario. I'm settled in with a base and defences.
1) AI sends it's first attack consisting of 10 machine gunners, 2 tanks and 1 humvee. I destroy it quite easily.
2) AI repeats first attack and I win again.
3) After roughly the same amount of time between attacks, the AI repeats the first attack yet again and I win again.
4) AI sends another attack this time consisting of 10 machine gunners, 2 tanks, 1 humvee and 1 cruise missile launcher. I have to send my army forward to take out the cruise missile launcher and I suffer a few losses but I still win.
5) Repeat until AI wins or AI loses.

So yeah, it seems C&C Generals does stick to the general cheat and execute weak attacks method of RTS AI.
^^Note 1: Someone else who has played C&C Generals may be able to comment further.

^^Note 2: It would be quite interesting to start a very simple RTS project just to attempt making a decent AI that doesn't cheat (ie ~3 building types, ~3 unit types, barebones minimalist RTS. Surely the AI could then be scaled up to a more realistic situation in a full blown RTS?). But then is a single unprofessional person could make a decent RTS AI then why don't the professionals do it? Maybe it's just a hell of a lot easier to make cheating AIs. I might just make this my next project :)
It sounds from that like the latest game is no different than the original C&C from the days of the 486, but with better graphics then?

This topic is closed to new replies.

Advertisement