Simulated Combat

doktorstick

Warlord
Joined
Aug 20, 2008
Messages
142
Howdy.

I've spent a fair bit of time going through the mechanisms used for combat, odds calculations, selection groups, etc. I have some ideas on how to achieve simulated combat without affecting game state. First though, I want to make sure I know what I'm building.

One immediate question that comes to mind is the actual act of simulation. Because of the nature of random rolls, a single A attacks B or stack SA versus SB may vary greatly between two mock combats. Not until many iterations are done with the pattern emerge. This is why the AI makes decisions based on odds.

Do you want full combat simulation?
What are the parameters of the simulation (number or runs, random rolls, fixed rolls, etc.)?

Do you want odds computation/power determinations with "fake" stacks?
Are the odds computations currently inaccurate or insufficient?

And for my insight, where would this be used (logically)? And where in code?

Thanks!
 
So, a full scale calculation of every possible result of a stack-to-stack conflict is ... exceedingly expensive, and results in far far too much data.

But the following problem needs an answer:
We have a city A, and nearby stacks B C and D.

Should we:
1> Gather forces, beat down defenses more, and attack later,
2> Get the hell out of counter-attack range,
3> Attack now!

A combat simulation lets the AI know what possibly could happen. It should be randomized -- the AI can run it a few times (maybe as few as 3 or 5), and make decisions about what the result of the simulations are.

For this to work, we need to be able to:
1> Simulate a battle between two units, where no actual changes are made to the units, but know the result of the conflict.
2> Factor in simulated damage to a unit in a future simulated conflict.
3> Pretend that a set of such conflict-results are "in play", and see who should fight next (ie, pick best defender/attacker).
4> Be able to pretend that units have moved location for the above purposes.

With 1 thorugh 3, the AI could simulate attacking an enemy city, and determine if the attack was "worth it" -- if all simulations show that the enemy takes minimal damage, while we lose lots of expensive troops, maybe we need more forces and/or to wait until the siege softens the target up more.
 
Full combat simulation with iterations to derive 'true odds' is going to be the most cpu-time expensive option because the order-of-attack problem is a variation of the "travelling salesman" problem. I think a better option would be a look-up table embedding human wisdom.

There should be a few heuristics added:

Order of movement and attack:
knock down cultural defense with naval units first
attack with aircraft next
attack with collateral damage units next
attack with best odds unit next

Define acceptable unit loss rate:
example: exchanging units 1 for 1 is good if AI has a local unit advantage

Define acceptable attack odds:
example: attacking at poor odds is good if an immediate same-turn followup attack will probably be at +90% (using 2 units to kill 1, achieving an exchange rate of 1-1)

Figuring the odds of the followup attack could be done via simulation as suggested, but this is where I would put in a look-up table. Ex: offline simulations show 2 infantry can take out another infantry on a plains tile, but 3 infantry are needed to take out infantry on a hill. The complication arises from variables: the hill could be wooded, the infantry could be dug in, there could be a river, the infantry could have a variety of promotions. So instead of having multiple tables just have one big table of initial combat odds vs. number of attacking units required to win.
 
The code already has a get-best-attacker, get-best-defender routines. I would not try all permutations of attack, but rather rely on those routines. If they need a-fixin', then they need a-fixin'. :)
 
Ok.

I think the odds calculations don't take into account an advantage in first strikes. If both sides have the same number of first strikes, there is no net affect.
 
*nod* -- we aren't attempting to pick the best attack order, as much as wanting the AI to have a better idea if "this is the turn I should try to attack".
 
Back
Top Bottom