[Tactical Combat AI] Using Roles for Units

What are Roles?

Reading a recent journal entry on starting work on AI got me thinking about the different ways to approach it.

One source of inspiration that I would suggest is the latest edition of Dungeons and Dragons, specifically, the way it suggests to the game master how the monsters should be used - by assigning Roles to them.

These roles are (simplifying a bit) Brute, Soldier, Lurker\Skirmisher and Artillery\Controller.

Brutes are big dumb monsters, usually not doing much more than attacking whoever's in their way. They have lots of hitpoints, good attack but poor defense.

Soldiers are more tactically minded, with solid defenses and attacks. They generally use more sophisticated tactics, such as defending the weaker members of their group (i.e. Artillery).

Lurkers\Skirmishers are units that rely on mobility and stealth to attack the weakest members of the party.

Artillery is a monster that does good damage, often ranged and\or Area of Effect,  but has poor defenses and hitpoints. Controllers also apply status effects.

How does this translate into Tactical Combat?

Well, each Role has its own AI in combat. Without any overriding orders from the overall battle strategy layer, each unit will do this:

Brute will head towards the enemy.

Soldier will either head towards a selected target, or stay put to protect the weaker units behind.

Lurker will attempt to go around and attack the weakest enemy unit.

Artillery will move out of harm's way, then use its ranged attacks or special abilities.

The Overall Battle Strategy

The overall battle strategy is determined by the "General" unit - normally, this would be the "Boss Monster" or the highest-ranked Artillery unit, but in a pinch, could be a high-rank Soldier (especially with some sort of Leadership trait providing bonuses to other units).

The General's AI decides, based on comparative strength (similiar to the calculations used for  what to do:

Battle is heavily in its favor - use "Attack at Will".

Battle is heavily against it - either retreat, or concentrate its attacks on a single unit.

Battle is even-sided - check whether it has advantage at long range or in close combat. If it has advantage at range, then issue order "Defend Ground", else "Advance Steady".

This leads to one of the following strategies -

Attack At Will - Brutes and Soldiers will head towards nearest target, Lurkers will flank and head towards the enemy they could do good damage against (this calculation should take into account how much damage the enemy can do if left unchecked), Artillery will attack the enemy they could do good damage against.

Defend Ground - Brutes and Soldiers will protect the Artillery, standing ahead of it (protecting a unit involves attacking units that can close into it at melee range). Artillery will attack the enemy they could do good damage against, without moving. Lurkers will move to flanks.

Advance Steady - Brutes and Soldiers advance ahead. Lurkers move out on flanks. Artillery can move ahead if this increases the damage done.

This logic can be re-evaluated at some point (each turn? every other turn?) - e.g. if the AI decides to defend ground, and then its artillery is taken down, either via lucky rolls or sovereign's magic, then it can decide to advance instead.

What logic needs to be understood?

Essentially, a number of evaluation routines are needed.

- Combat force evaluation (own, opponents)
- Melee\Ranged combat force evaluation
- Best target (damage dealt versus defenses), parametrized by distance, and whether unit can move to attack them

So, what does it bring?

This brings a level of abstraction to thinking about the units the AI will use, and gives it an element of teamwork.

With this approach, the same AI can represent a battle against a half-dozen archers, accompanied by four knights, as well as against several poisonous spiders  and darklings.

How can this tie in elsewhere in the game?

Units can have preferences for traits\levelups depending on their role (note - traits are just suggestions, I don't know what FE traits actually are):

Brutes would favor traits such as Paired Weapons (trades a shield for a second weapon, bonus to attack\damage at cost of defense).

Lurkers would favor Stealth (grants "Hidden" at start of combat - +5 melee defense , +10 ranged defense until first attack), and Poison Strike.

Soldiers would favor Heavy Armor (allows units to wear heavy armor, increasing defense), Toughness (extra hitpoints), Leadership (bonus to other units), and Entangling Strike (prevents enemies struck from moving, though not attacking for one turn).

Artillery would favor Marksmanship (reduces long-range shooting penalties), area of effect and battlefield control attacks.

Next, it allows parametrization at civilization level:

Leaders can have preferences towards unit types they use - one that prefers an army of mostly Brutes will be a different enemy from another that uses Soldiers and Artillery, even if both were to be leaders of the same civilization otherwise.

Furthermore, this can drive preferences for tech:

Heavy Armor is more interesting for Soldier using civilizations.
Ranged Weapons are for Artillery users.
Melee Weapons are for Brutes.
Accessories and Mounts are for Lurkers (increasing speed).

6,708 views 5 replies
Reply #1 Top

me likey.

frogboy, please try to apply this

harpo

 

Reply #2 Top

A good general wins the battle before it's fought, this sounds like a good start to me.

Reply #3 Top

Excellent posting on how to approach tactical AI. Sounds almost like how I would do tactical battles myself, as a human player. This should definitely be implemented.

Reply #4 Top

I agree that this would work, though I have no idea how difficult it would be to implement.  Its a pretty useful system for the DM though- it makes running a battle and keeping it from devolving into a rush kill situation (it helps that 4th edition is more closely tied to a map vs. previous editions) much simpler.  It also gives you some insight into monster behavior and design by using the role as a rough template.  After all, a brute behaves much differently than a controler.

Reply #5 Top

It is hard to say what can and can’t be implemented for an AI when we do not know the rules of the combat engine which can greatly affect the overall desirable tactics:

Will there be zones of control?

The presence of zones of control (meaning that once a unit engages in melee combat, it cannot easily move away, either taking a free attack from the enemy or simply unable to move), opens a lot of tactical options – e.g. having the melee units guard the ranged ones by engaging any approaching enemies.

Will units taking damage suffer from reduced effectiveness?

If not, then the correct strategy is to gang up on a single unit, trying to take it out - this is rather limiting. If yes, then it makes sense for both AI and player to have units at full health attack other units at full health, whilst wounded units square off against wounded units (since a powerful but wounded unit can be destroyed by a weaker unit at full health).

Master of Magic had solved this elegantly by having multiple figures per unit, which would take damage and get killed – so a six-figure unit at 50% health would only have three figures remaining, and its damage-dealing capacity would be reduced. Of course, the biggest monsters and most powerful heroes were single-figure units, thus negating the benefits of this approach.

How many turns will it take for units to cross the battlefield?

Depending on the answer to this, ranged weapons may end up being over- or under-powered. How would an all archer army fare versus an all melee one?

---

However, that being said, there are a few things that Roles can suggest at its basics for the AI:

Brutes will attack the nearest foe they can reach; if they can reach more than one foe this turn, they will go for the one with the highest threat level that they can do significant amount of damage to. Once stuck in melee combat, they will continue striking the enemy.

Lurkers behave similarly to Brutes, but will be prepared to break off melee combat to go for more juicy targets (e.g. attacking the ranged units hidden behind the melee ones).

Artillery stays back and attacks at range.

Soldiers, if defending Artillery, will be seeking to engage any unengaged enemies so that they melee with the Soldier, rather than going past them.

---

This can be further elaborated with Traits, and priorities that can be picked up at unit creation:

A favourite trait for Soldiers would be Immobilizing Strike – melee attacks now have the extra ability (both the attacker and the defender are held in place for their next turn - can attack normally but cannot move from their spots). Soldiers would prioritize high defences.

A favourite trait for Lurkers would be Slippery (available later in the tech tree than Immobilizing Strike) – granting freedom of movement and preventing from being held in place. Lurkers would prioritize good mobility and high initiative, as well as abilities that allow them to inflict status effects and disable units even if they fail to kill them outright. Examples would be “Poisoned Weapon”, that inflicts poison damage each turn on the target unit, and Crippling Strike, which reduces their accuracy.

Brutes would be the simplest – favouring attack over defense, they would be the classic cannon fodder.

Artillery is also fairly simple – favouring anything that aids in ranged attacks, such as Marksmanship, reducing the penalties for long-distance shots, Rapid Fire (an alternative firing mode, sacrificing accuracy for more damage).