AI Architectures


Game AI is about one thing: Maximizing the players fun.

When selecting the right tool as your AI solution for your game,consider that sometimes it can be a mistake to build an AI that thinks too hard.

This is specially noticed when the NPC actions does not match the players mental model of what the AI is doing. Even if this actions are correct and logical within the algorithm, they may end up looking random or just plain wrong.

In the following article, I will be rating the different AI architectures by this keypoints:

  • Authorial Control:  How easy it will be to make the NPC do a specific set of actions.
  • Implementation: How easy it will be to develop and debug this architecture.
  • Nondeterminism: How unpredictable will the NPC be to the player.
  • Scalability: As the project grows, how easy it will be to add new behaviors.
  • Reusability: When writing an action, how likely it will be able to be used by other NPC.
Disclaimer: This article is marely speculationon my part, I am still working to implement every one of this architectures. So please if there is something that you feel is missing, I encourage you to contact me.

Finite State Machines


  • Authorial Control: Misc_StarMisc_StarMisc_StarMisc_StarMisc_HalfStar
  • Implementation: Misc_StarMisc_StarMisc_StarMisc_StarMisc_Star
  • Nondeterminism: Misc_Star (Unless you random)
  • Scalability: Misc_StarMisc_HalfStar
  • Reusability: Misc_StarMisc_StarMisc_HalfStar

The easiest of the lot, I you haven’t done one I highly encourage you to start with them since they will be extremely useful for non AI stuff (Like UI).

Each state represents an action, and there can only be one active at a time. This states are connected by transitions, which are described manually by the designer. A new state will be set once certain conditions are met.

They are fantastic when handling NPCs that doesn’t make use of a lot of behaviors. This is mostly due to how transitions are made, which makes every new addition of a new state a problem since you will have to describe how it interacts with all the others states.

Find out more at: Link

Variants: Hierarchical FSM

Game Examples: Half-Life ,  Hotline Miami

Behavior Trees


  • Authorial Control: Misc_StarMisc_StarMisc_StarMisc_HalfStar
  • Implementation:Misc_StarMisc_StarMisc_Star (If you build them yourself) Misc_StarMisc_StarMisc_StarMisc_StarMisc_HalfStar(If you use a tool)
  • Nondeterminism:Misc_StarMisc_Star
  • Scalability:Misc_StarMisc_StarMisc_Star
  • Reusability:Misc_StarMisc_StarMisc_StarMisc_HalfStar

This architecture is currently the most popular one around AI devs, mostly because of its great scalability and clearness for designers.

Behavior Trees have their own set of rules, without going into much detail, lets say you got a specific set of building blocks that dictate how the rules of the tree will be evaluated and traversed. You code the custom actions for the NPC and use this blocks to make the logic.

Most of the time they start from the left and if the if the branch is unsuccessful they will keep moving to the other branches until they find a successful or running action.

Find out more at: Link

Game Examples: Halo, Don’t Starve , Project Zomboid

Utility Systems


  • Authorial Control: Misc_StarMisc_HalfStar
  • Implementation: Misc_StarMisc_StarMisc_Star
  • Nondeterminism: Misc_StarMisc_StarMisc_StarMisc_HalfStar
  • Scalability: Misc_StarMisc_StarMisc_StarMisc_HalfStar
  • Reusability: Misc_StarMisc_StarMisc_StarMisc_HalfStar

Their focus is on non-boolean decision making, they are meant to take decisions based on certain analog values that describe how much the NPC wants to do something.

As the game situation changes the NPC desire values will change which will make the actions score to change as well, increasing the likelihood of them being selected.

Utility systems are also great post-release since most of the time you wont need to modify the NPC base to add new elements.

Find out more at:

Game Examples: The Sims



  • Authorial Control: Misc_StarMisc_Star
  • Implementation: Misc_StarMisc_StarMisc_HalfStar
  • Nondeterminism: Misc_StarMisc_StarMisc_StarMisc_Star
  • Scalability: Misc_StarMisc_StarMisc_StarMisc_StarMisc_HalfStar
  • Reusability: Misc_StarMisc_StarMisc_StarMisc_Star

Planners are a great long term solution  for a project. They are specially good when you are handling a lot of enemy types, or when you are planning to keep expanding your AI behaviors.

They will allow the NPC to create its own approaches to solving problems by being provided with a description on how the game world works.

Keep in mind planners need a complementary Goal Selection Method, since the NPC needs a goal first before creating a plan for it.

Find out more at: Link

Variants: G.O.A.P. , Hierarchical Task Networks

Game Examples: F.E.A.R. , S.T.A.L.K.E.R.

Machine Learning


  • Authorial Control: Misc_HalfStar
  • Implementation: Misc_StarMisc_Star
  • Nondeterminism: Misc_StarMisc_StarMisc_StarMisc_StarMisc_Star
  • Scalability: Misc_Star
  • Reusability: Misc_Star 

Their job is usually inside games with a very complex set of rules where it becomes very hard to the programmer to describe the transitions or weight the states appropriately.

This is usually not the case in games tho, since most of the time its a necessity to control this parameters to get the desired experience for the player.

The focus of machine learning is to find a maximized way for the AI to play your game under a set of rules you describe. It will iterate through generations based on a scoring system called “fitness” which will allow the algorithm to know how successful was on that run. After that, a new generation will be made with some random modifications in its inputs.

This process will be repeated until the AI behaves in an acceptable way.

Find out more at: Link

Variants: Neural Networks

Game Examples: Supreme Commander 2


A final note about cheating in your AI:

This is a pretty sensitive matter. If you get caught you will disrupt the illusion of intelligence we are trying to achieve instantly, it will also had an instant negative feeling in the player experience.

However, if you can pull it off it will make the NPC look much more smarter than it actually is, and that is always a good thing on our end.

A great tip when building a smart looking NPC is to make it extremely communicative of what is it doing, wheather it will be verbally expressed, with actions or even visually with icons.