feheroes

This article may need cleanup to meet quality standards.
Please help improve this if you can. The Discussion page may contain suggestions.
Reason: "Old, either poorly researched, contains inaccuracies or outdated, or all of the above."

The artificial intelligence (abbreviated as AI) refers to the entity/computer controlling the enemy units whenever a player battles on a map, or the player's units when Auto-Battle is used. This includes the decision-making the computer uses to move/attack a player's units.

Movement patterns

All enemies in the game will wait until they are engaged by the player, after which the enemy will begin attacking the player units. An enemy unit is engaged if it is attacked or a player unit is present in its danger zone during the enemy phase. Enemies may also use Assists regardless of whether they have been engaged. Additionally, enemies may have additional attributes that control their individual behavior:

The movement pattern of an enemy unit remains the same throughout the map but may change across different difficulties of the same map, such as waiting for different numbers of turns. Movement patterns for Story maps and Paralogue maps are carried over when the maps are used in other game modes such as Training Tower and Voting Gauntlet.

Reinforcements

Main article: Reinforcements

Spawn criteria

Foes from a map may be separated into initial units or reinforcements. At the end of each enemy phase, the game iterates through the list of reinforcement entries, checks if each entry satisfies all of the following requirements, and spawns a foe in that case:

Slot index

The slot index is a unique integer value assigned to each unit, which increases by 1 for each unit spawned, including initial units. Reinforcements always have greater slot indices than units that have appeared before them; among reinforcements spawned on the same turn, units defined later in the map files have greater slot indices than units defined earlier. Killing a unit does not free up its slot index; newer reinforcements, including those from the same reinforcement entry, will occupy new slot indices. Player units also have slot indices which are defined according to their team/brigade's unit order.

Arena and Rival Domains maps place their initial units according to the slot indices of both teams and the internal order of the initial spawn positions. The slot index is also the final tiebreaker for several AI actions; therefore, the relative slot order between units spawned together can be determined empirically, without reading the map files.

Spawn location

When a unit is considered for spawning, its designated cell might be occupied and the game has to search for another cell to place the unit. This is done by ordering all cells on the map that are unoccupied by units, as shown below:

  1. If the spawn location is unoccupied, it is always chosen even if it is inaccessible.
  2. If the spawn location is occupied by another unit, cells closer to the spawn position have higher priority over farther cells.
    • If there is a continuous path between the cell and the spawn position, such that all cells on the path (including both endpoints) are accessible by the unit's move type, all such cells with the shortest path length, ignoring terrain costs, are chosen.
    • Otherwise, if there are accessible cells blocked off by inaccessible terrain, all the cells with the shortest distance to the spawn location, ignoring terrain costs, are chosen.
    • Otherwise, all the inaccessible cells with the shortest distance to the spawn location, ignoring terrain costs, are chosen.
  3. Among the chosen cells with the same distance, cells closer to the top have higher priority over cells closer to the bottom.
  4. Among those cells on the same row, cells closer to the right have higher priority over cells to the left.

The cell with the highest priority is then used to spawn the unit. Each reinforcement entry finishes spawning before the next entry checks for an unoccupied cell. If all cells are occupied (which does not occur through normal gameplay), the unit is not spawned and waits until any cell is unoccupied at the end of an enemy phase.

Arena Rules

The following rules will count for Arena only. If none of a player's units are within range of the enemy:

The order enemy units will move is as follows:
  1. Melee Units (No Support Skill)
  2. Ranged Units (No Support Skill)
  3. Melee Units (With Support Skill)
  4. Ranged Units (With Support Skill)
  5. Units with no Attack (e.g. Healers)
The enemy AI units when moving will have a target unit they will move towards, and they will always move in a way to shrink the distance to that target unit. The enemy units will not stop moving towards this target unit unless they are in combat range. The enemy selects targets based on who they would deal the most damage to. They will choose a target, if they have no target or their previous target died. Any  Bonuses or  Penalties will be taken into account at that time, however, they will not change their target, even if there is a more favorable one at that time.
They will not take their attack range in consideration, which means they will choose the shortest path to move towards their target's location rather the shortest path towards a square that attacks the target.
If a unit has the option to use an assist to bring a friendly unit out of fewer enemy danger zones, it will have priority over any other actions (except for Dance skills Dance skills) and do so. If multiple units are able to perform this action, it will use the slot order as a tiebreaker.
If a unit has the option to move onto a defensive tile before doing the planned action (Support), it will do so.
If no other factors are involved, the unit will move in a way that seeks to equalize X-axis and Y-axis distance towards said target.
If any breakable blocks are in the path between the enemy unit and his designated target, he will destroy the breakable blocks over moving aside even if a free path is available.

If a player's units are within range of the enemy:

If the battles do the same amount of damage, it will prioritize the battles that will result in less damage taken.
The AI will take defensive tiles into consideration.
For both kills and damage dealt, the AI does NOT take into consideration whether a kill can be achieved by having a unit move into a free space. For example, if a melee unit is blocking a space that a ranged unit can move to get a kill, the enemy AI will not take this into consideration.
Additionally, a Refresher will prioritize attacking a unit over using Dance skills Dance skills on another target even if the Dance skill Dance skill would lead to a kill afterwards.
It will, however, check the situation of the map after every move, so if a melee unit moved away to attack a unit and frees up the space for a range unit to kill a unit or deal more damage than the other possible battles, it will do so.
If a battle would result in less than 5 damage done to the target unit, the battle will have a lower priority (among all battles) and they will prioritize their Bonus Assist skills (e.g. Icon Skill Assist Rally Attack) or Dance skills Dance skills over initiating said battle. It still retains a higher priority over any movement without the use of any assist skill.
However, they will still initiate the battle, even if the unit dies before dealing damage (e.g. Vantage) or does no damage to the target unit, if they have no Bonus Assist skills available.
Healing
If an enemy AI has a healing skill (e.g. Icon Skill Assist Heal, Icon Skill Assist Ardent Sacrifice), then the enemy AI will heal the unit with the most missing HP[citation needed].
If it is possible to attack an enemy, they will do so and prioritize it over healing based on the rules above.

Non-Arena Rules

Under construction icon-blue
This article is under construction.
Please help review and edit this page.


Whether the AI starts to move as soon as it can or some condition has to be fulfilled first depends on the map itself. Aside from that, the AI can act in 2 different ways concerning battles and decision making. The first is the aggressive stance, where the AI uses the same rules as the Arena (Listed above) and focus on dealing as much damage to the foe as possible. The second is the defensive stance, where the AI will choose to prioritize their own survival. The AI for Auto-Battle appears to use the defensive stance.

Defensive Stance rules