Ai Algorithm implementation using a Hierarchical Statemachine
3D, Ai Solution
Ai Capture the Flag Concept
This project was entirely based on learning about Ai algorithms commonly used currently in industry, and to choose one and use it to solve an Ai solution, in this case Capture the Flag. The choice is then justified it in a technical report, and compared to other options that we had considered.
My Role: Solo Developer
Deciding which algorithm to use for this solution was a difficult choice for me, the main contenders were Goal Oriented Action Planning, Decision Trees, and State machines. My initial research drew me towards decision trees, as they are well known for being easy to maintain, extremely efficient, whilst being popular therefore having a good amount of online resources to use for assisting development. However, I settled with StateMachines after reading about the qualities of the Hierarchical extension, which combats many of the known issues with the base algorithm. Firstly, it suited the playstyle of the capture the flag environment, where players are often in specific play states; Attacking, Defending or Healing. Secondly, it allows for multiple types of actions to be taken within that state, much like you would expect to see a normal player defending their flag. Finally, It was far more scalable than the base algorithm.
​
The reason I mention goal-oriented behaviour is due to its potential for creating intelligent and more interactive agents. Correct implementation could have seen far more emergent gameplay between the two teams. However, I decided against it due to the known issues with balancing and perfecting goals and actions as well as the increased complexity of implementing such a solution within the given timeframe. Ultimately I concluded that this was the right choice.
​
The biggest challenge in development was implementing the regroup and retreat states for the Ai. Controlling their judgment on when to retreat or carry on towards an objective/Enemy needed a lot of fine-tuning as there were instances where they would perform unexpectedly. My solution for ai who were carrying flags or travelling to heal was to have them check the area in front of them based on the direction they were travelling in if any enemies they could see were not in this area then they would carry on towards their goal. Otherwise, they would retreat. For agents who were involved in combat, I set them to check on the number of enemies and compare it with the number of friendlies in view, if they were outnumbered they would retreat to the nearest friendly, they would also regroup if the friendly they could see was too far away from the fight. The only addition I would make to this would be to add a memory system to the Ai allowing them to remember other agents who go around corners before them or are behind them, as in this demo you can see they forget instantly, I have however added this to the agents in my latest project Imperium Games.
​
The full report plus its source can be downloaded from the buttons below.
​
Key Skills
-
C# And Unity
-
Understanding of a range of Ai algorithms and how to design them
-
Implementation of Hierarchical State machines
-
Writing of technical reports
Features
-
Knowing when to heal
-
Supporting friendly flag carriers
-
Knowing when they are outnumbered
-
Prioritising goals based on realtime information (Heal/Flee or continue to objective)
-
Taking Powerups
-
Retreating