1
\$\begingroup\$

I'm working on a Fire Emblem style tactical engine, and looking into the AI.

I have it working so enemies will find the best target within their movement/attack range, but what about when no units are within range- for example at the start of the map when they're far away. Who do they decide to move towards?

Does it just pick out the weakest from the player units? Does it go for the nearest?

\$\endgroup\$
  • 1
    \$\begingroup\$ Totally depends on your type of AI you want. You could let it look ahead a few moves (like which is the best target I can reach in X moves and attack there), let it move to closest or even do some regroup/ turtle tactic and wait for an enemy to approach or move in a general direction if you have some fog of war (can't see enemy locations when out of range) \$\endgroup\$ – Zibelas Jun 16 at 9:00
0
\$\begingroup\$

I have seen a lot of turn-based tactics games where enemy units simply stay idle unless there is an enemy in range. This isn't necessarily the strongest solution and might allow a clever player to cheese if they can somehow find a way to damage enemies while still ending the turn outside of their movement range (Some of the Disgaea games allowed that exploit under some circumstances). But it can still be a "good enough" solution for many games. It also allows you to create longer combat scenarios where the player army slowly progresses through a larger but sparsely formatted enemy army step-by-step. If the AI is too aggressive at moving in on the player instead of waiting for them to arrive, then this becomes very difficult to design.

But let's say you do want to go the extra mile and have an AI which behaves more aggressively.

Just walking in the direction of the closest enemy unit is a valid option. I would prototype this, playtest a bit and see how it works out. But if you want the AI to be extra smart, you could use the rating function you are already using to determine targets, but apply it to all enemy units and add the distance as another factor. So the AI will balance target distance with target desirability when deciding which target to close in on. The ideal balance factor is a matter of preference. A "perfect" AI would measure distance in turns, not in tiles. But measuring by tiles might make the AI appear more human. It would replicate the human bias for attacking enemies which look closer even though from a purely game-mechanical view all units which can be reached within one turn are technically the same distance.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Great answer and I'd only be repeating you with mine but one thing I'd definitely also consider would be that if you are rating your the enemy, you could also rate the AI defenders / attackers and send them to where they are most mismatched or outnumbered, providing the AI with backup. \$\endgroup\$ – Stephen Jun 16 at 10:22
  • \$\begingroup\$ Thanks, good points to consider! \$\endgroup\$ – Muckington Jun 16 at 11:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.