🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

AI opponent army composition, what units to produce?

Started by
6 comments, last by totesmagotes 6 years ago

Hi!
Im doing a modern version of total war-esque strategy game: you control cities and produce military units that form armies. Armies move on the map and fight other armies they encounter in a separate view (a tactical map covering the local terrain).

My problem is how to figure out how to make the ai factions produce a good mix of units to put up a challange for the player. There is many unit types and they hard counter other unit types:
Tanks, vehicles, infantry, choppers, aircrafts
Anti-air, anti-tank, anti-vehicle and more balanced unit damage profiles.

One idea is to just let the ai build "balanced armies". Some inf, some air, some tanks etc. But this makes it a good tactic for the player to make "all in" armies. For example en entire army of tanks. Yes they will be weak to the few anti-tank units the enemy has, but once these are disposed of, the enemy army is very vulnerable. Not to mension an "all aircraft army" (many units can hardly damage aircrafts at all). 

To counter this, I was thinking to allow the ai to "shift" some units if the player army they encounter is very geared towards something like "all air". This would mean replacing some units for some other units of similar value (shift some tanks to anti-air vehicles or fighter planes). How much of this would a player accept before feeling the game "cheats"? Or do you have another good idea to solve it.

Thanks!

Advertisement

One organic way to approach this is to leverage terrain, and it's limiting factors. Suppose you have a country that's surrounded by treacherous mountain ranges on several flanks, you could impose penalties on world map movement (Based on the composition of the army), or in battles to certain units (tanks, vehicles, ect.) a stalled tank is a sitting duck ;) Also, while tanks are powerful, they should have at the very least one set back;  they aren't cheap. Further still, they shouldn't be so easy/time conducive to construct that a player can throw 12,000 tanks at any problem :D 

This way the AI chooses it's units to best fit it's home terrain, or the terrains of the adjacent nations it seeks to conquer. Also, you should leveraging scouting as well. AIs shouldn't be able to cheat, and know the composition of an army, and vice-versa for the player. But, with a successful, but dangerous (for your expensive scout) mission, why not?

Panzer/Tank hunters should be relatively cheap to make as well, considering that the weakest part of any tanks is it's tracks, and a well placed sock covered in axle grease, and filled with c4 can blow the tracks off a tank (So essentially just infantry soldiers running around with sock bombs)

Terrain cannot be used much, the game is more similar to "Risk" in a sense, so armies move on a world map. Also I dont see how this would automatically help countering some unit types?

Yes anti-tank units are already cheaper than tanks, but I need to make the ai produce them at the right time :). However the nature of such units make them very weak against non-tanks!

But if you cannot view the enenemy army in advance, and the cheating (shifting) isnt so big, how would you know that the ai is cheating? :) I'm thinking it could work, but im not sure if other games do this. If you attack the same ai army the same turn with different armies, yes you would def see something fishy is going on!

 

I'm not sure how Total War does it (Also a huge fan of the series) but if everytime I attacked a province, and l do a quick save (Cause I got whooped by an AI), and reload, and decide to tool with the composition of my army (before the next attempt at assault), only to find that the AIs army changed without them using a scout (Remember Total War uses these types of units, Shogun = Ninjas, Warhammer = Heros, Rome = Centuari, ect. even the AI uses them making me believe TW takes a more organic route), or anything else, Id find that a bit mood-killing.

You can still make it work, but you'd have to be crafty for your average RTS player not to catch on.

Also, terrain makes a HUGE difference. In Total War if I route my units through certain terrain I suffer attrition, and movement penalties (Enemy Territory, moving during the winter, ect.), and on the battle map soldiers can suffer fatigue when being asked to run everywhere they go, or being asked to run to the top of a hill. In fact, side topic, one of my favorite tactics in Shogun 2 was placing my yari/yari samurai men at the top of a hill, and having the opposing AI charge their troops towards me (Shogun 2s AI was easy to antagonize into bad decisions :D ). By the time they ran into my wall of pikes their morale was gone, and they were exhausted. I could stretch 1 troop to 4 troops of the AIs (in most scenarios)  

Now, for a risk style game I still feel like you can factor this in. Tanks (and most vehicles to be fair) work best when you have flat, level, non-treacherous, dry terrain. Mountain ranges, regions that are experiencing rains (muddy), ect. should incur a penalty of movement (Have you seen a truck in the mud?), and a penalty during battle. These can be as simple as arbitrary deductions of base-line stats depending on the environment.

I made a prototype of a game with Risk-style map and total war-inspired combat mechanics. The way the AI was selecting units to produce was the following:

1. create plans to attack enemy provinces and run combat simulation a few times (battle outcomes were somewhat chaotic)

2. based on combat results, identify enemy units that present danger to AI's current troops (based on the cost of units that the enemy unit killed in combat simulation runs)

3. go through provinces and do the following:

3.1. queue production of units that counter identified dangerous enemy units

3.2 if any money and production capacity is left, queue production of the  cheapest units

3.3. if any money is left, consider replacing production of the cheapest units with randomly selected more powerful units

This part of the prototype worked reasonably well, though obviously the planning was rather shortsighted since only border enemy provinces were taken into consideration during step 1.

Hope this helps.

Hmm interesting!

I've been working on a strategy game myself, and thinking about the same kind of thing.

If you know from the get go what beats what, you could write a matchup graph ahead of time,

and use that to determine what should be built. Say, you match up a unit to itself, the result is 1, since they're evenly matched.

If you match up say, a bomber vs a tank, you get 8, since you've figured out ahead of time that in a fight, 1 bomber is worth 8 tanks. If you match up a tank vs a bomber, you get 0, because they're useless against bombers. Say some kind of anti-tank infantry is worth 1.8 tank (cost-wise). When you matchup tank vs anti-tank infantry, you get 0.55.

When trying to figure out their composition, the AI will try and maximize the total values.

A simpler solution: Make a list of units and their counters. Try and spend as much money on the enemy's counters as they did on their units. If you can do that consistently, you'll win every battle.

This topic is closed to new replies.

Advertisement