Advertisement

military combat AI

Started by September 16, 2001 02:25 PM
9 comments, last by Damocles 23 years, 2 months ago
I have been looking into military tactics and AI to simulate these. Assuming we''re working on a flat grid, we need code that can handle squad formations, attack tactics (flanking, ambushing, sniping, etc) and tactical retreats. Retreats are easy enough, simply decide if the units are outgunned and run. Formations are nto so hard, simply give the various squad members positions relative to the squad commander. But the assault tactics, these are a whole other matter. Flanking I''m guessing can be done by splitting the squad up and giving two groups waypoints that circle round the enemy, and giving the third group orders to stay and try and pin down the enemy. But ambushes on the fly, this is a real doozie. Scripting an ambush is easy, but how do I make a small squad of troops that have retreated setup an ambush for thier pursuers? The decision to make an ambush is relatively easy, but setting up an ambush is a wholw other matter. The only way I can think of is to litter every level with ambush points. Each point would relate to an ambush locale and each time the squad commander enters one of these locales the decision to/not to ambush is made. then athe troops adopt the various related ambush points and wait. Does anybody else have any other ideas on this - preferrable ideas that would allow for true dynamic ambush creation. I want to be able to do this so that I can create psuedo random levels.
------------------------------------------[New Delta Games] | [Sliders]
An ambush, I guess, would be a pre-planned maneuver. Set up a group of troops at an area of terrain that gives them an advantage over units approaching from the enemy''s direction, and then send units in, but have them retreat as soon as they are being followed by a sufficient strength enemy force.

I think a "strategic importance map" would help in a situation like this. Choke points (detected by an algorithm of some sort) would be assigned high values; hills near valleys would have high values, hills overlooking chokepoints have even higher values, etc. If you have a "strategic importance" map, then do a breadth-first Djitska-style search from the enemy base (or areas of high enemy concentration - I''d use influence maps to determine that) to the nearest area with a strategic value of X or greater. Set up your ambush at that strategic point, and then lure them in.
Advertisement
It''s not quite as simple as a strategic map. It''s not a open terrain style of game, it''s a squad vs squad / unit vs unit tactical combat game set in locations such as offce buildings, factories, etc. The choke point idea is pretty much the same as my ambush locale idea I had before. I think the strategic map idea could be used to locate potential ambush areas, but the problem still remains of finding appropriate cover and attack points relative to the decided ambush location. To decide these things on the fly poses a lot of questions such as how do the units evalute a position compared to the other positions? They need ot be able to attack and to be hidden. This would require predicted knowledge of the enemy''s approach route.
------------------------------------------[New Delta Games] | [Sliders]
Now, about flanking... It''s not attacking from the side that''s the point; it''s attacking the enemy where he''s weakest that is. The flank normally is the weakest position, because, unlike the center, it is not supported by the two flanks on either side. But the real point is to just attack the enemy where he''s weakest. Therefore, I think a good solution is this: Determine where masses of enemy units are (using influence maps). Then use A* to find the lowest cost path (where each tile''s cost is equal to the enemy''s strength on the influence map there) from where your troops are to the center of that group. Then just follow that path. That means the AI will find enemy weaknesses and exploit them.

You can use this system with all kinds of things as your "destination" - areas of high strategic importance (see prev. post), enemy infrastructure or supply lines, etc.

I think that''s a decent way to handle it.
OK, I had been thinking of something more along the lines of Age of Kings. You''re thinking of something more like modern-day Myth: Soulblighter?

That means the emphasis shifts from strategy to tactics.

So now you need ways to evaluate the "ambush fitness" of a location. How about this:

- Pathfind from expected enemy starting point (might just be the direction with the most unexplored, or the direction they seem to be coming from) to whatever areas you want to defend. Make a "traffic map" that all possible paths add to. Shorter paths, I guess, would add more.
- Areas with high "sniping fitnesses" will be those where the sum of all "traffic" values in its LOS are high, but are near areas with with low values (eg: hiding place next to area with view of enemy)
- A chokepoint is a small area with a high net traffic value.
- Areas that have a chokepoint in their LOS but a low total traffic value in their LOS are "ambush points."
- The best "Ambush points" are covered by "Sniping points."
Oooh, traffic. That''s a good idea, I hadn''t even considered the idea of traffic. (I''ve been thinking mostly in small one squad against one squad situations) Although a potential traffic map will be quite hard to construct dynamically.

If we assume the units doing the ambush (the opposing units will be player controlled) don''t have unexplored areas and know there way around that''ll reduce the error level. If the maps have strategic value points placed carefully during map design time that''ll help to better calculate traffic flow.

Yeah, I like the idea of potential traffic maps, I think I''ll run with it and see how it works.
------------------------------------------[New Delta Games] | [Sliders]
Advertisement
To give the appearance of real flanking, give your units pathfinding a modified fitness value so that tiles in the enemy''s front LOS is higher than those from the sides and behind. This will make them split off and attack from the sides/rear.

If you attack with an infantry force from the front to engage the enemy, and then attack the flanks with a faster unit, say cavalry, using slash & run tactics, you''ll decimate the enemy with minimal losses, since they won''t have time to regroup and focus their attacks.
"NPCs will be inherited from the basic Entity class. They will be fully independent, and carry out their own lives oblivious to the world around them ... that is, until you set them on fire ..." -- Merrick
Although it''s not a medieval game (it''s modern day SWAT style) the fast flanking units still remains. I''ve already looked into the various aspects of flanking. It''s really just the ambushing that was the bit I wanted help on.

The infantry that you spoke of will be armoured, rapid fire units that will lay down fire to try and pin the opposing force into place while a small group of fast, lightly armoured units will circle round and attempt to force the opponents to make thier move where the cover fire will rip them to shreds.
------------------------------------------[New Delta Games] | [Sliders]
Well, as mentioned before, your best bet would be to find a bottleneck (valley/clearing) which your enemy traverses regularly, or would choose to traverse due to low movement costs.

Once you ascertain such a point, you want to position your troops where their LOS is uninhibited, but the enemy will be unable to see them (easily). Choose higher ground if possible, or at the very least a defensive position (maybe improvise some earthworks/barricades).

Ideally you''d have your long range units up high, with a clear shot, and have your ground troops positioned to sandwich the enemy as they come through. You could also implement using waves of different units to attack, e.g. attack first with long-range, and as the enemy moves for cover (which would usually mean higher movement costs), you''d send in quick units to attack. Then when the enemy comes out into the open to engage these units, have the long rangers pick them off.

The basic idea you should have is : ambushers are under cover, with good LOS. Ambushees are in open, and can''t see/attack ambushers.

The way I personally go about choosing an ambush spot is two-step. Initially, I go by LOS & movement cost to determine somewhere that might be good for an ambush. Then I try it out, and if it works, I create a struct for that area which contains information like the ratio of Enemy Killed : Allies Killed, vantage points, defensive structures, etc.

Then later on, I use these two in combination to ascertain the better places to ambush, so essentially my units get smarter as the game progresses to match the skill of the player, rather than simply increasing their stats to make it harder.
"NPCs will be inherited from the basic Entity class. They will be fully independent, and carry out their own lives oblivious to the world around them ... that is, until you set them on fire ..." -- Merrick
Althouhg your ideas are geared towards strategy games like AOE or TA, I think they could be adapted to suit this game. As it is a small squad vs squad style of game where the player controls one squad of units trying to eradicate a level (building/location) of enemy units while saving any hostages, the idea of learning from an ambush is going to have very little impact. If the player''s squad is killed during the ambush then the bad guys win and the learning is irrelevant. If the bad guys die then to make the other bad guys learn from this would be a bit of a cheat. Although maybe that''d be the best way. If the bad guys that weren''t involved learn by it, it would stop the player form re-using the same location over and over as a ''lambs to the slaughter'' style of play.

Because there won''t be much in the way of unit distinctions (eg, no archers/cavalry style distinctions) the long range/short range combo idea wouldn''t pan out that well. In order to stop the player form simply taking cover, the bad guys can lob grenades in thier direction to try and smoke them out. Although a back-up plan will be needed in case they run out of grenades. The other problem of course is that the player can simply do the same and smoke out the bad guys with grenades.

I want to try and keep the game more of a tactical combat simulator rather than the usual ''my side''s bigger so we win'' style of play. And this means that the bad guys will need to be able to match wits with the player. I''m thiking the best way to do this is to draw up plans for as many co-ordinated attack styles as possible then devise methods of deciding which attack would best suit the situation the units find themselves in.
------------------------------------------[New Delta Games] | [Sliders]

This topic is closed to new replies.

Advertisement