# Combining pathfinding with global AI objectives

I'm making a turn-based strategy game using Java and LibGDX. Now I want to code the AI.

I haven't written the AI code yet. I've simply designed it. The AI will have two components, one focused in tactics and resource management (create troops, determine who have strategical advantage, detect important objectives, etc) and a individual component, focused in assign the work to each unit, examine its possibilites and move the unit.

Now I'm facing an important problem. The map where the action take place is a grid-based map. Each terrain has different movement cost. I read about pathfinding and I think A* is a very good option to determine a good route between two points. However, imagine I have an unit with movement = 5 (i.e, it can move 5 tiles of movement cost = 1). My tactical AI has found an objective at a distance d = 20 tiles (Manhattan distance) from my unit.

My problem is the following: the unit won't be able to reach the objective in one turn. So the AI will have to store a list of position and execute them in various turns. I don't know how to solve this.

PS. In my unit code, I have a list called selectionMarks which stores all the possible places where the unit can go in this turn. This places are calculated recursively using a getSelectionMarks function.

If you are allowing a unit to spend all movement points, you can have a variable like traveledSoFar which holds the movement units spent on a tile at the end of a turn.
• I like the traveledSoFar idea. I'm working right now in the problem and I'm trying to find some solutions to it. That can be an useful variable. – VictorSeven Aug 25 '14 at 11:53