
Creating a possibility map (FPS)
We'll learn how to create an awareness behavior for the AI character later, so for now we will just be using simple Boolean variables to determine if the player is near our position and what direction it is facing. Taking that into consideration, let's break our image into trigger zones to define when our enemy AI should react.

The YES zones represents the area that triggers our AI to change its behavior from the passive to offensive state. The NO zones represent the area that doesn't have an impact on our AI behavior. I've divided the YES zones into three because we want our AI character to react differently according to the player's position. If the player comes from the right side (YES R), the enemy has a wall that can be used for cover; if it comes from the left side (YES L), we can't use that wall anymore, and once the player is in the middle (YES M), the AI can only move backwards inside of the building.
Let's prepare our script for the enemy AI. In this example, we will use the C# language, but you can adapt the script to any programming language that you prefer, as the principles remains the same. The variables that we'll be using for now are Health, statePassive, stateAggressive, and stateDefensive:
public class Enemy : MonoBehaviour {
private int Health = 100;
private bool statePassive;
private bool stateAggressive;
private bool stateDefensive;
// Use this for initialisation
void Start () {
}
// Update is called once per frame
void Update () {
}
}
Now that we know the basic information required for the AI, we need to think about when those states will be used and how the AI will choose between the three available options. For this, we'll use a possibility map. We already know the areas that trigger our character, and we have already chosen the three behavior states, so it's time to plan the transitions and reactions according to the player's position and behavior.

Our enemy AI can go from PASSIVE to DEFENSIVE or AGGRESSIVE, from AGGRESSIVE to DEFENSIVE, and from DEFENSIVE to AGGRESSIVE, but once our AI knows that the player is around, it will never go back to the passive behavior.