AI System
Background
The gameplay of Naja Medjai was inspired by the like of DarkSouls (FromSoftware, 2011) and Bloodbourne (FromSoftware, 2015), infamous as games that focused on difficult combat encounters with seemingly unpredictable enemies, which can over time, trial and error, can be learned to be beaten by a player.
To ape the style of gameplay, the combat encounters in the game required enemies that focus specifically on the player, and have the enemies use the players location and actions to influence their available behaviours.
Three total “boss style” enemies were made for the game, and two “lesser AI” with (with a variant each). Each “boss” enemy shared the same set of states, but with drastically different outcomes of behaviours engaged.
The difficulty of the enemies was designed to a difficult degree, to provide a challenge to the player, similar to the Souls-like style of games. The idea is that the player, through frequent encounters with the boss AI, the player gains iterative knowledge which is built up upon until the player can defeat the enemy (Guzsvinecz and Szűcs, 2024).




Figure One: The elemental enemies
Figure Two: Geb, God of Earth
Figure Three: Ra, God of The Sun
Figure Four: Set, God of Chaos and Storms
Finite State Machine
To controls the flow of actions by the AI, a Finite State machine was used to provide an easy to produce system that only needed to contain pre-constructed states based on the available actions of one other actor – the player. Through the Finate State Machine, the enemies engage in one single state, which handles the logic for entering, updating each frame and then exiting the state. (Bevilacqua, 2013).
In Naja Medjai, the BossStateManager script handles the AI’s global variables for each behaviour state to access, such as current target and Unity components such as NavMesh Agent and Collider, and controls the current state being engaged with.
Figure Five: Extract of the BossStateManager as seen from the inspector.
The BossStateManager. Where the global variables and the central point at which the enemy AI methods are called via it’s update function.
Quasi-Utility AI
Utility AI was considered in the AI development of Naja Medjai as it provides for AI to provide a prioritization of certain behaviours over others, as some behaviours provide better outcomes based on the given values the AI must analyse (Świechowski, 2024).
Influence of Utility AI in Naja Medjai’s AI can be seen with the decision-making state the AI in enter, the “Combat State”. Unless told otherwise, all states upon completion enter the Combat State where a quasi-Utility function is completed; based upon the distance the boss has towards the player, split between close, medium and far distances, and then also based upon the level of “aggression” the boss character has, ranging from 0 to 1, the AI chooses it’s next set of states to enter into, known as “States And Weights”.
The CombatState. Where the decision making of the enemy AI is completed:
States And Weights and Aggression Behaviour
The States and Weights are groupings of pre-existing states the AI can entered, sorted into groupings appropriate to the pre-configured situation the AI is to analyse – distance to the player, and then the level of “aggression” of the AI.
The distance is a simple check as to the magnitude of the vector between the target and the current AI agent.
The “aggression” level is determined via “Boss Value” script, which contains an instance of a serializable class called “Behaviours” which provides for an ever-increasing “aggression” value of the enemy AI during combat, which is also affected via player hits on an enemy AI, as well as by the behaviour engaged by the enemy itself; aggressive behaviours reduce aggression, while defensive abilities increase aggression.
This aggression changing values allows a flow between aggression and defensiveness, giving the player variety and breathing room during combat. This distance to the player further influences the behaviours the boss engages with; either charging in from a distance when aggressive or teleporting away when close and defensive.
Figure Six: Extract of the BossDecisionWeighting Inspector showcasing the divide of sections for the states the AI enemy can enter based on distance and aggression level.
Figure Seven: Extract of the BossValues Inspector, with the highlighted Behaviour class showing the aggression of the AI enemy.
Figure Eight: Video showcasing the changing aggression and movement of states the AI flows through.
BossDecisionWeightings. The script that provide the enemy AI the type of states they can enter depending on distance and aggression level to the player:
Scriptable Object States
The states the bosses are supplied with aim to replicate challenging and flowing flights – a variety of aggressive attacking states from differing distances have been provided, along with retreating and movement-based states to stimulate defensive or tactical abilities.
Each state is an inheritance from a scriptable object base state, “BossBaseState” (Unity Technologies, n.d.). This allows each boss in Naja Medjai to have custom values assigned for each inherited state behaviour that the boss may have due to exposed properties. Furthermore, abstracted elements such as handling aggression remain contained to just the parent class of the “BossBaseState”.
The use of inheritance allows for overriding existing methods allowing new behaviours to be created within the same state for a variation in boss behaviour. The exposed values further contributed towards this also. This can be seen explicitly in the Dash State, whereby Ra, Set and Geb have their own Dash States inherit from the parent Dash State, yet the three have different dashing behaviour. However, calling on DashState ensures the correct behaviours still run due to the polymorphic nature of how the BossStateManager calls behaviour states.
Figure Ten: Extract of the DashState scriptable object values that can be customised within the inspector.
BossBaseState. The basis for all states the AI enter into:
Decision Overrides and Increasing Difficulty during Fights.
The base states of the AI provide for overrides of the usual decision-making logic to allow for breaks in behaviour for gameplay purposes – for example, Set uses a stamina system which drains for each attack, and when this is reduced to zero, it activates the override behaviour to stop the usual decision making of the bosses, and forces the next state to “recover”.
Also, the enemy health is tied to the number of melees the enemy can combine in a row. This, acting like an override, compels the boss to drain more aggression by acting more aggressive. The serves the purpose of increasing enemy difficulty during fighting due to the less chance for player to find a gap to strike the enemy back and serves to change the rate of aggression flowing between high and low changing boss behaviour swings. This mimics the dynamic difficulty identified as a core function of the Souls-Like games (Guzsvinecz and Szűcs, 2024).
References
FromSoftware (2011) Dark Souls [video game]. Published by Namco Bandai Games. Available on: PlayStation 3, Xbox 360, Microsoft Windows.
FromSoftware (2015) Bloodborne [video game]. Published by Sony Computer Entertainment. Available on: PlayStation 4.
Guzsvinecz, T. and Szűcs, J. (2024) ‘Game theory and strategic decision-making in the Dark Souls games’, in Game Theory – Computational Aspects and Applications. IntechOpen. Available at: http://dx.doi.org/10.5772/intechopen.1008456 (Accessed: 25 May 2025).
Bevilacqua, F. (2013) Finite state machines: theory and implementation. Available at: https://code.tutsplus.com/finite-state-machines-theory-and-implementation--gamedev-11867t (Accessed: 25 May 2025).
Świechowski, M. (2024) ‘Fuzzy utility AI for handling uncertainty in video game bots implementation’, 2024 IEEE Congress on Evolutionary Computation (CEC), Yokohama, Japan, 30 June–5 July. IEEE. doi: 10.1109/CEC60901.2024.10612092.
Unity Technologies (n.d.) ScriptableObject. Available at: https://docs.unity3d.com/6000.1/Documentation/Manual/class-ScriptableObject.html (Accessed: 25 May 2025).