AI error at long distances?

This course is absolutely amazing :slight_smile:

I’m looking for some suggestions: right now, if the enemies are too far away (10+ squares?), the AI will mindlessly walk toward (0,0) and will do it in an “L” shape (not even a diagonal). As such:

  1. Can anyone give me advice on how to extend the sight of the enemyAI?

or

  1. How can I alter the AI to say “if no one is near, stand still”

Any advice would be appreicated!

1 Like

If no enemy is near enough to the tested tile to attack, then it should be returning an result with a score of zero. What I would do is after evaluating all of the possible BestActions, if the score is zero, then simply do nothing.

        if (bestEnemyAIAction != null && bestEnemyAIAction.actionValue>0 && enemyUnit.TrySpendActionPointsToTakeAction(bestBaseAction))
        {
            bestBaseAction.TakeAction(bestEnemyAIAction.gridPosition, onEnemyAIActionComplete);
            return true;
        }
        else
        {
            return false;
        }
3 Likes

Worked like a charm - thank you so much!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms