Version 0.50 Discussion Thread

I would like to share my thoughts about defense algorithms with you:

The more complex an algorithm is the more weaknesses it has.

So lets keep it simple: (well, I hope it will be ;) )
The Situation: An enemy attack stack is in sight.

1. Based on strength of attack stack and closeness to cities, threat levels are assigned to every city.

2. Cities free up defenders based on threat level.

3. Freed up defenders move to city the attack stack is closest to. Counter attacking is considered.
( So there is no "downhill flow" but rather a direct movement towards the enemy )

4. Siege and flanking units should attack.
( I think a direct attack order for all (most) siege units is just fine. maybe add a little grouping here. )

5. Consider counter attacking.

Thats about it.
If the city cannot be defended maybe a retreat is a good choice?

Another thought is looking for good defense plots near a threatened city and station some defenders there. This is to split/avoid enemy siege attacks. The defenders outside the city could stay healthy and would therefore be a good choice for counterattacking the enemy.

Greetings and thanks for this great mod,
RiHatz
 
1> Computationally, the costs of medium to long-range pathing is high, especially when done on a per-unit basis over an area as large as an entire empire. So units far away cannot be expected to plan to attack (even if you have railroads).

That is the reason behind "downhill flow" -- by restricting these decisions to be local, we reduce reinforcement flow to a near-city-to-near-city problem, which is short range and (should be) cheap to compute in most maps.

It is an attempt to get units stationed at the far side of a reasonably large empire to reinforce the side that boarders an enemy, and then flow back if there is a treaty.

2> As it stands, the level of defenders tends to be exactly what the AI thinks it needs. There is no pool of 'defenders able to be freed up' in the current code that I could tease out. A threatening attack tends to spike the number of defenders needed, and the AI responds to that ... by hoarding any units that are currently in excess.

Cities farther away than local naturally do not send reinforcements, because pathing costs seemed to be considered too high in the code to do long-range "should I come help" checks.

3> An attack with insufficient forces is as bad, or sometimes worse, than no attack at all. Being able to evaluate "can the current stack threaten a target stack" is currently only doable on a stack-to-stack basis, and the AI's ability to do it ... sucks. For the most part, the AI ends up making these decisions on a "just do it" basis (when the AI tosses an attack stack at a defending city), or on a unit-by-unit basis in other cases.

4> As noted, building up a counter-attack stack in the city being sieged opens up an easy exploit. It might be easier to leave that exploit open and have troops ralley there, at least to start.

The downside, of course, is that it means that the units being routed for the counter-attack end up being open to counter-counter attacks by the invading force...
 
Another tricky problem is the "what if" game. If we stomp a stack, how many units will be free threat-wise? Because we can afford to contemplate attacking with units that we would otherwise hold back if the stack we are attacking is defeated...

I don't quite understand what you mean better. I am not seeing things as deeply.

@Ri-Hatz
2. Cities free up defenders based on threat level.
There is a lot in that "algorithm". I would like to see the AI react faster to attacks. Here are some important algorithms:

1) Yakk's threat level and how that translates into promotions at the time defense is required.
2) Yakk's threat level and how that translates into unit builds a head of time based on city defense, territorial defense and the possible formation of a "reaction stack". In other words the division between garrison specialists, mellee, seige and flank.
3) Stack reaction simulatation code that can do pretty good assessments of reaction stack odds of success. (difficult considering computation resource considerations!)
4) Stack reaction formation code. This should be virtual reaction stacks that could be assembled based on stackable units and their arrival time in areas of likely threat. This is routinely assessed a head of time. If there is no real target tile to use, then the area on the map that is selected for possible formation is a tile in the centre of the threat area.
5) Stack deployment code. This is code that pulls the trigger on forming a real reaction stack. It has to be a trigger (highly non-linear). Standard efficient "downhill flow" Yakk algorithm's take precedence at all times. However if a virtual reaction stack runs through the reaction simulator ok, then stackable units that can get to the site of contest within say 2 turns, are actually assembled and deployed.
6) What happens after the stack contest, I think this is what Yakk is asking?

What happens if these algorithms were actually built, and then we find that we want even more sophisticated AI behaviour? Can they be reused?
 
I don't quite understand what you mean better. I am not seeing things as deeply.

I guess something like: If the AI defeats the attack stack, then it doesn't need the high numbers of defenders anymore. Thus the AI can consider using more defenders in the reaction stack if that will make the reaction stack large enough to defeat the attack stack.
 
*nod*, some units shouldn't be considered for some categories. In particular, units that are "does not gain defensive bonuses" should only be used for city defense when there isn't any point in them trying to attack.

On the other hand, axemen and spearmen often make perfectly fine defenders, and perfectly fine stack-stompers.

...

Another tricky problem is the "what if" game. If we stomp a stack, how many units will be free threat-wise? Because we can afford to contemplate attacking with units that we would otherwise hold back if the stack we are attacking is defeated...
 
Yeah stacks are like vortexes for units. I see that now. Like Yakk was saying with a "downhill" flow for city defenders, there is a real chance to turn stacks into massive gravitational points. If the enemy has invaded with a big stack that is so large a commitment that homeland defense is comprimised, a reaction stack against it should consider throwing in the kitchen sink to defeat the stack.

Sometimes though, it is better not to defeat an enemies primary stack. If the enemy is overly weakened, then your rivals begin to pick at them like vultures before you get the chance. So for humans, it's about controlled weakening of the enemy even from a defense standpoint.

Reaction stack behaviour might have to take that into consideration.
Cheers.
 
Back
Top Bottom