This is maybe a question that's been asked 100 times 1,000 different ways. I apologize for that :)

I'm in the process of building the AI for a game I'm working on. The game is a turn based one, in the vein of Final Fantasy but also has a set of things that happen in real time (reactions). I've experimented with FSM, HFSMs, and Behavior Trees. None of them felt "right" to me and all felt either too limiting or too generic / big.

The idea I'm toying with now is something like a "Rules engine" that could be likened to the Gambit system from Final Fantasy 12. I would have a set of predefined personalities. Each of these personalities would have a set of conditions it would check on each event (Turn start, time to react, etc). These conditions would be priority ordered, and the first one that returns true would be the action I take. These conditions can also point to a "choice" action, which is just an action that will make a choice based on some Utility function. Sort of a mix of FSM/HFSM and a Utility Function approach.

So, a "gambit" with the personality of "Healer" may look something like this:

(ON) Ally HP = 0% -> Choose "Relife" spell

(ON) Ally HP < 50% -> Choose Heal spell

(ON) Self HP < 65% -> Choose Heal spell

(ON) Ally Debuff -> Choose Debuff Removal spell

(ON) Ally Lost Buff -> Choose Buff spell

Likewise, a "gambit" with the personality of "Agressor" may look like this:

(ON) Foe HP < 10% -> Choose Attack skill

(ON) Foe any -> Choose target -> Choose Attack skill

(ON) Self Lost Buff -> Choose Buff spell

(ON) Foe HP = 0% -> Taunt the player

What I like about this approach is it makes sense in my head. It also would be extremely easy to build an "AI Editor" with an approach like this. What I'm worried about is.. would it be too limiting? Would it maybe get too complicated?

Does anyone have any experience with AIs in Turn Based games that could maybe provide me some insight into this approach.. or suggest a different approach?

Many thanks in advance!!!


2 Answers 2


For a game like you described you might consider going for a full Planner based solution. This allows you to describe simple transformations of the world state the AI can perform. Essentially the AI plans a number of moves ahead of time to reach its desired goal. This approach is computationally expensive but for a turn based game it's a great fit over classical min/max and alpha/beta pruning techniques.

The issue you run into with the Rule Based System you described is having to constantly tweak conditionals and re-prioritize the list. When the list of rules grow larger they become nontrivial to fix small issues without affecting everything else. Utility systems have similar issues when a large number of utility functions constantly struggle between themselves.

STRIPS is a well known planner algorithm that was used very effectively in F.E.A.R http://en.wikipedia.org/wiki/STRIPS

Jeff Orkin's paper on his STRIPS implementation for F.E.A.R is a great starting place. A SDK to F.E.A.R is also available to take a look at some of the AI implementation details. http://web.media.mit.edu/~jorkin/gdc2006_orkin_jeff_fear.pdf

  • \$\begingroup\$ Thank you for this. That was a great article. I looked into a goals based approach when I first started. I'm still green when it comes to AI so some things didn't make sense to me. Still don't. For instance, how would I decide what each actors goal is for a given scenario. The same actor could have the goal to heal an ally or cast a buff on another ally. How do I decide which is the best goal? \$\endgroup\$
    – Jason L.
    Commented Jun 7, 2013 at 23:27
  • \$\begingroup\$ Your first approach can be to list goals based on priority. Typically there is an upper bound to the number of planned moves you can make toward a goal. If the AI can't find a plan to a goal it will move on to a less desirable goal. F.E.A.R for example had a simple ASM on top of the STRIPS planner that was used to choose the AI's current goal. \$\endgroup\$ Commented Jun 8, 2013 at 1:06
  • \$\begingroup\$ Thanks for that. I'm going to do a bit more reading on this as it might also work for what I'm going for. It sounds to me like finding the current goal could be done in something not unlike a FSM or the gambit system I outlined. "If an Ally is less than 50% of HP, my desire to heal them is X", where X is some number between 0 -1. Would that be accurate? \$\endgroup\$
    – Jason L.
    Commented Jun 10, 2013 at 13:34
  • \$\begingroup\$ What goal the AI has can be set in my different ways. The key idea is to separate the Goal from the Execution. A planner uses a list of actions to determine how it will go about doing something. This lets your AI be flexible or "emergent" while letting the programmer or designer focus on small actions that are independent. \$\endgroup\$ Commented Jun 11, 2013 at 9:30
  • \$\begingroup\$ I am marking this as the answer as it forced me to think about things in a different way, which is very helpful. Ultimately, I went with a mixed approach (see below), though :) \$\endgroup\$
    – Jason L.
    Commented Jul 3, 2013 at 12:54

I decided that I would build a system that is a mix of the various different AI systems out there. I just felt that was the best approach for my game. It is heavily influenced by Rule Based systems, but also has some features from STRIPs, Behavior Trees, and Finite State Machines.

Each "node" in my AI has a method I call depending on the type (Decision, Condition, or Action). They all also have a Precondition and Postcondition step, which let me evaluate if I should even run that action or if that action was successful. If all 3 methods return true, I can continue onto the next node (or, if the last node, I'm done).

Each method also takes in the current BattleState and the current AIState. The AIState is modified by each behavior, as needed. The BattleState is NOT changed by the AI, but instead by the battle system as a result of the AI.

I really hope that makes sense. If not, here's a screen shot of my AI Editor. It shows a "stupid" personality tree that I can evaluate from left to right when needed. I can also pre-evaluate a node based on where the entity will be in X seconds.

enter image description here

Each node has a bit of smarts in it that are not represented in the editor. For instance, the "ChooseTarget" action has a bunch of smarts about which target should be chosen: Who has the highest threat, who has the lowest health, etc. I could represent all these decisions in the tree but I didn't see the need for that... yet.

Each one of these nodes are also executable independently (mostly). Only certain nodes depend on the nodes before them. And, more accurately, only a few nodes have the POSSIBILITY of depending on the node before them. For example, "UseAttackSkill on Target" depends on the node before it because it needs a target set in the AIState. If that was, say, "UseAttackSkill on Enemy Any", I could execute that node without regard for it's current location in the behavior tree.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .