AI Ticket System

The Goal

The goal of this prototype was to create an AI who executes actions based on its surroundings, as a member of a team. The Ticket System seemed like the best approach for this type of objective. Using a ticket system I could easily set priority of tickets, set maximum number of each ticket type available, and decide who gets to take the ticket. The AI actors can also drop their current ticket for a higher priority one. This all makes for a more dynamic and responsive team playing AI.

The foundation of each class is written in C++, and used in Blueprints to complete the prototype. This helped speed up the process by not having to recompile and restart the editor all the time, while also providing the speed increase that comes with using functions and algorithms written in C++.




The Ticket System

The Ticket System is responsible for keeping track of which AI has priority on the individual tickets. This means that a ticket will go to the best suited AI. The best suited AI is, for example, the closest one to the target. The ticket system also keeps track of how many tickets of each type is allowed. This can be use to prohibit multiple AIs to have the same objective. The system will always try to push the highest priority ticket to the active AI.

The ticket system is set to auto-generate a selection of tickets at start. Other tickets are generated in runtime, for example when an actor gets below a certain percentage of health a "Heal" ticket will be generated.




The Scoring System

When an actor has an action it wants to execute, it generates a heat map of all tiles in range. This heat map scores tiles depending on a couple of factors:

  • Current action

  • Next action

  • Enemies responses to first action

  • Environmental features (cover, walls)

  • Proximity to target (objective, friendly, enemy)

  • If the move is offensive (scoring, attacking), or defensive (healing or hiding)

After the actor has picked its best scoring tile, it broadcasts its intention to all enemies. They can now react, either by shooting or by dodging. After each enemy announced its reactions, the active actor calculates its second action. It then runs its first action, waits for enemy reactions to execute, then runs its second action.

Code snippet from tile scoring system calculating Objective Score bonus.

The Rules

The AI has a strict set of game rules to adhere to. I chose these rules to give the AI more depth, and to give them the need to think multiple steps ahead.

Each AI can execute two successive actions each activation, and can also react to other AI actions when they are themself NOT active. An activation executes in following order:

  1. Active AI takes top priority ticket IF it is the best fit, OR calculates best action if not using ticket system.

  2. Active AI generates a heat map from the given action.

  3. Active AI declares its intention to enemies.

  4. Enemy AI in line of sight of active AI can react to active AI action.

  5. Active AI recalculates its second action according to enemy AI reactions.

  6. Active AI executes action 1.

  7. Enemy AI reacts to active AI.

  8. Active AI executes action 2.

The goal of each team is to HOLD objectives (purple tiles) while denying enemies holding objectives by killing them.

1. Active actor calculates first action

Here the active actor grabs a ticket to score the objective. It then generates a heat map and sets a target tile, before broadcasts its intention to enemies.

2. Enemies decides on reaction

Enemies that have Line of Sight to the active actor decides how to react.

3. Active actor calculates second action

The active actor now decides on its second action based on its active ticket and enemy reactions.

4. Active actor runs first action


5. Enemies executes reactions


6. Active actor runs second action


Here is that sequence in action!

A short clip showing the first rounds of actions

Video of a full round.