• Register
Post news RSS Devlog #1: The Mind of the Enemy

Take a look at our process to create the Artificial Intelligence in Caapora - Oath of the Forest! When you need a very reactionary AI, you know you are in for a challenge. Luckily, our resident programmer, André, is on the job.

Posted by on

Article written by André Vitorino

Debug.Log("Greeting and Salutations!")


Hi, my name is André Vitorino, and I'm the Programmer here at Koala Kompany. Today I would like to give you some insight on how the enemy AI in Caapora - Oath of the Forest works at the moment.

Planning

Since the very start of the planning phase, the team had already discussed how we wanted for the basic AI to act, containing the basics of a stealth AI:

  • Get suspicious if it sees the player
  • Starts heading towards the player if they are seen long enough
  • Attack the player after it is sure it's the player
  • Hear sounds
  • Fix machines that it hears being destroyed.

Player leaves shadow behind


On top of these, we also had plans for an extra feature that would affect the whole enemy AI and make it more unique and interesting: a Paranoia Status. As machines or other surrounding objects are destroyed, or the player is spotted but not enough to make the AI enter the Move To Player or Attack Player behaviours, it would increment the individual AI Paranoia Level. If this State were to reach a random Paranoia Maximum per AI agent, it had the chance to either run from the level or start attacking other enemies.

Unfortunately, there were two main concerns with this AI feature. Firstly, it would be significantly harder to develop and test; Secondly, this meant we were removing challenge elements from the stealth game, possibly making the gameplay too easy or passive. Thus, the group concluded

Prototype Phase

The early AI during prototyping worked with a Finite State Machine (FSM) – it would run through the behaviours checking which one it should do based on its current state. This was a crude implementation meant only to exemplify and test the idea. Adding any new feature, even during prototyping, proved to be a big challenge sometimes, producing copious amounts of bugs and little refactors. So, once it served its purpose and the game entered the production phase, a new AI implementation was in order.

Caapora - FiniteStateMachine schematic


At the time of publishing this article, the AI has switched completely into a Behaviour Tree. As the name implies, the AI is akin to a reversed tree. It starts at its root and moves down, moving left to right, to check the branches of the tree. However, unlike the FSM, a Behaviour Tree can execute several branches at once, each of them with its own separated behaviours, making it extremely easy to expand, debug, change or fix.

At its core, the AI works the same, with the addition of the AI being able to see broken machines and containing a “Memory” to know what it saw, didn't see and where, and what it already checked as you can see here:

Caapora -  BehaviourTree schematic


Since we don't want the enemies to ignore the current state they're in (lower left) or the player entering their vision (lower center) these two are always forced to fail, this means that upon completion, even if it succeeds in executing a leaf, it still moves into the next leaves. This allows it to still check if it contains anything important on its memory or the player is in sight before returning to its default patrol.

Tools and Pathing of and AI Enemy

The AI reacts to the effects of the players actions


If you made it this far, congratulations, there's no bug in your behaviour tree!

We hope to see you in our next post. See ya!


Don't forget to check our Twitter for minor updates and news! Follow us on Koala Kompany

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.

Related Games
Related Engines
Unity
Unity Commercial
Related Groups
Koala Kompany
Koala Kompany Developer