ID:1870090
 
(See the best response by Lummox JR.)
Code:


Problem description:

After 3 weeks I'm about to finish coding the game AI but got stuck in the unit strategy AI. I'm talking about a total war/civilization like strategy AI. I've had many ideas but the implementations are disappointing...
So what is the main idea behind creating/moving and giving units targets to attack and towns to capture ensuring that AI towns are protected???
I think you'd want to look into AI solutions for ant or bee-like behavior, as they could be applicable to this situation. You might want a certain percentage of units to attack one target, a certain percent another, etc. So you'd want some kind of master controller deciding the objectives, and it could set incentives appropriately to get the units to divide up.

Alternatively, a master controller could simply choose the units specifically based on distance to target, health, and other considerations, trying to keep their power balanced according to the way it wanted to apply them.
My idea is similar I mean I have defensive and offensive units, targets , percentages to divide targets and units and also guerrilla tactics and decoys. The problem is that I don't want the player to cause my troops to go back and forth from attack to defense because he moves his own troops back and forth. I mean I want my units to pursue enemies but not that much that makes them to stray from their goal. Thought of creating a radius of pursue.
But I dont know whether it's best too attack easy targets or go in for decisive attacks where the enemy units are stacked.
Best response
Perhaps your AI should strategize in terms of risk/reward. Which or units targets pose the greatest threat? What benefits might you achieve from taking out a specific target early? (E.g., access to a choke point to get from A to B or likewise prevent an enemy crossing, destroying the enemy's fuel reserves, cutting off an enemy supply line.)

In some ways the decisions might be easier if units have synergy. The top goals should be to either defang or kill the enemy as quickly as possible, reducing as much of their power as you can. That is, if your enemy has a unit that provides cover to other units that can attack you effectively but are otherwise weak, then you want to take out that cover unit ASAP because then the rate of possible damage you can do is accelerated. If a weak scout is accompanied by a guard and you need to take out both units, the scout should be your target because taking him out reduces that particular group to just one enemy--unless you have a very quick way of dispatching the guard, in which case go for it.

All decisions can be boiled down to:
  • What is this target's strength against me?
    • How much damage does it do?
    • How often does it do damage?
  • How does this target benefit the enemy's defenses?
    • How much damage does it prevent me from doing to other units?
    • How many units, and at what strength, benefit from its defenses?
  • To what extent does this unit impede my ability to attack other targets? (This folds somewhat into the defense question, but it also ties into big-picture strategic decisions like capturing choke points.)
  • To what extent does this unit enhance the enemy's ability to attack me? (Again this folds into the attack, but it's really meant for the strategic overview.)
  • How will all of the above change if I take this unit out?
  • How quickly can I take out this target?
Taking those questions and coming up with some general scenarios:
  • A big shield that's deflecting most damage away from a single soldier is not a high-priority target unless that soldier is high-priority as well. A shield that's protecting 100 soldiers who are doing you damage, or are in the way of your objective, is a much higher priority.
  • In a group of four grunts and one artillery cannon, your primary target is probably the cannon; it does the most damage to the most people. But if it only fires infrequently, you can afford to prioritize the grunts. Also of course, the grunts may be in the way of targeting it, which then makes them higher-priority.
  • If a wall stands between you and easy access to a relatively undefended part of enemy territory, it's a high-value target.
  • If a bridge is allowing the enemy access to you, and you don't need that bridge, it's a high-value target.