A simplistic game level which includes the implementation of a companion AI agent alongside numerous enemy AI agents. This was produced for a module focusing on artificial intelligence at the University of Portsmouth.
The project makes use of several techniques such as finite state machines, behaviour trees, steering behaviours and a perception system.
Companion AI - Finite State Machine
The companion AI (coloured in blue) uses an embedded finite state machine to switch between different states.
The video shows a finite state machine diagram, followed by some gameplay where the companion can be seen following the player, attacking an enemy, and waiting.
Alongside acting autonomously, the player is also able to control the companion AI, commanding it to follow, wander or wait.
Enemy AI - Custom Behaviour Tree
The enemy AI is controlled by a custom behaviour tree, shown at the start of the video.
Various composite nodes, including selector and sequence nodes, were used to create more complex behaviours. The behaviour tree also uses conditional decorator nodes to ensure certain behaviours only run if the conditions are met.
A blackboard was implemented to store common and important information, such as the player's location.
The enemies have various behaviours including 'combat', 'hunt', 'flee', 'get health' and 'patrol'.
Steering Behaviours
Various steering behaviours were implemented for the AI agents, including the ability to seek, flee, evade, pursue, wander and more.
The dynamic movement algorithm makes use of several
forces to smoothly change the velocity of the agent, as opposed to simply being moving or idle.
forces to smoothly change the velocity of the agent, as opposed to simply being moving or idle.
The video shows the companion AI currently using the wander steering behaviour. Furthermore, when combined with other techniques, the use of steering behaviours allowed the companion AI to follow the player, seek health packs when needed, or evade the enemy.
Perception System
A custom perception system was implemented with assistance from a workshop session.
The perception system could be visualised - with the line of sight to the player also being displayed - and would be affected by objects in the environment.
The functionality was expanded upon to include a memory system for the enemy AI agents. After losing line of sight of the player or companion AI, the enemies would only remember the player's last known location for a set duration.