Combining pathfinding with global AI objectives

Posted by V_Programmer on Game Development See other posts from Game Development or by V_Programmer
Published on 2014-08-24T13:46:45Z Indexed on 2014/08/24 16:29 UTC
Read the original article Hit count: 260

Filed under:
|
|
|
|

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 calculed recursively using a "getSelectionMarks" function.

Any help is appreciated :D

© Game Development or respective owner

Related posts about libgdx

Related posts about ai