I'm developing AI for a strategy game in the style of Advance Wars.
When it is AI’s turn, it performs the highest-scoring action (Attack, Capture, etc.) for each unit it controls.
However, if a unit cannot perform any action (that is, if there is nothing within its range to interact with), it either stays where it is or moves to random locations (Movement action).
How can this problem be solved?
For example, advancing toward the enemy's headquarters or advancing toward the current front line, for example