AI Projects
The following section is a collection of the AI-related project I've worked on over the past few years. The AI I have the greatest passion for working on is NPC systems and gameplay-related AI systems. I started working on AI systems to understand how AI systems work in strategy games like Age of Empires 2 and a youtube channel called "AI and Games." Even though I am early in my career, I have some project ideas revolving around a behavior tree in Unity and procedurally generated puzzle games.

AI Hieracacly Finite State Machine
Release Date: December 2023

After working on the initial Finite State Machine, I decided it would be an excellent choice to remake certain parts of the code to improve how the states worked with each other. Before starting the rework, I wanted to make a rough list of the main things that needed updating. The highest priority items that needed updating were the state transitions and moving creation methods to a higher group state in charge of various states. The grouping I landed on was Non-Combat, Alert, and Combat parent states. The first parent state (Non-Combat) was meant to be in charge of the patrolling and idle state and checked when it would transition to the alert states. I also implemented an alert parent state, controlling the alert and searching states. The final parent state was the combat state, which contained all the previously mentioned states of cover, attack, and aggression. As part of this rework, I also had to create an image to conceptualize better how different states interacted with each other through their transitions. I have the image below as a way for the readers to understand better the current states and how they transition.


My main challenge when recreating the transition was ensuring all states/methods were updated with the proper changes. This is because, at different times, when testing more minor transitions between certain states, the AI system would have a problem where it would fully transition, or the animation system would break as it might have stopped receiving the correct information it initially expected. The solution I used to solve this was to fully update all of the code and use the UI Debug system to explain better the transitions that occurred. This gave me a better understanding of where each AI was in the state process.

AI Finite State Machine
Release Date: April 2023
This project involved designing and working on a Finite State Machine (FSM) in Unity. This allowed me to learn the entire design and creation process for working with an AI system for a game. This version of the FSM contains five (5) main states: Patrol, Idle, Aggression, Attack, and Cover, which the AI will transition to depending on whether it sees the player, proximity to said player vs the distance to cover points, and a few other internal reasons. Working on the FSM allowed me to gain a whole new level of understanding about correctly designing and working with an AI system for a game. Still, it has motivated me to continue working on this project, finding ways to improve it and working on other AI systems.

The project began by creating a research and design document that helped structure what I had learned throughout the project and plan the AI system. In the PDF document below, I have a collection of the primary research I have been able to do, which includes navigation meshes, FSM, Behavior Trees, and Utility AI, as well as the design of all the states that the NPC would have and related trait systems for the NPCs.


Each NPC also has a standard methods script for movement and an AI State Manager for current state control and essential information. Separately, a GameObject named the Director AI manages the NPCs as a group, limiting the number of NPCs in the Attack state to maintain gameplay balance and other important decisions related to all NPCs.


The NPCs start in the Patrol state with assigned patrol and cover positions. Then, whenever the player enters visual range or fires a weapon nearby, NPCs will transition to an Aggression state. At this point, the NPC calculates a utility value to determine its willingness to attack or seek cover based on player distance and nearby cover points. A higher utility value represents a higher willingness to attack the player and transition to the attack state. The value is stored in the AI State Manager script, and the NPC is added to a list in the Director AI with other NPCs in the Aggression state.


The Director AI periodically processes the list above of NPCs in the Aggression state (Currently every 2 seconds). Next, it checks if the current limit of NPCs in the Attack state has been reached; otherwise, it will probabilistically select the Attack or Cover state with a higher utility value with a lower threshold for the Attack state. In the Attack state, the NPC approaches the player if necessary and fires its weapon, while those in the Cover state choose the closest cover point behind a piece of the cover relative to the player. Finally, if the line of sight is lost, the NPCs switch to the Searching state and go to the player's last known position. At which point, if not in range will return to the Patrol state.