Project Title: Study in Goal-Oriented AI
Development: C# / XNA
My Role: AI Programmer
The following project was largely an exploration in AI development, specifically related to Goal-Oriented planning for individual and groups of units. In that light, this project, entitled the 'Spooky House' project, serves to create a simulator based on the needs and desires of each AI unit within the game.
The application is user directed, allowing the player to add / remove units, add / remove facilities, and alter the corresponding Action values and results within the menu component. By adding Ghosts to the simulation, they will begin wandering the map using simple pathfinding procedures. However, as facilities become available to interact with, the Ghosts will begin to follow a priority list dependent on their possible needs and Actions.
Goal-Oriented Behavior allows the Ghosts to keep track of their current pressure values, otherwise known as Goals. Goals may either be removed upon completing a specific objective, or they may simply be suppressed for a set amount of time. In the case of the Spooky House application, Ghosts have 4 basic Goals: Hunger, Sleep, Bath, and Wander. These types of Goals can only be suppressed by having Ghosts fulfill Actions, procedures that will allow them to reduce the insistence of their Goals.
In this scenario, the user can place 3 facilities to resolve Hunger, Sleep, and Bath Goals. Furthermore, the Wander Goal is simply completed by allowing the Ghosts to move around the level as a form of exercise. Once any 4 of the Ghost Goals reaches a high enough discontentment value, the Ghost will attempt to prioritize it and look for a corresponding Action.
In most scenarios, the Ghost will simply locate a facility that will fulfill the Action, claim the territory, and proceed to move to the target location to resolve the Action. However, sometimes there may be no available Action, or the facility may already be claimed by another Ghost. In these situations, the Ghost will move onto the next best Action, possibly resolving another insistent Goal, or resorting to a Wander Action.
Available to the user for adjustment, each Action inevitably contributes to the insistence growth of other Goals. For instance, a Ghost that proceeds to fulfill its Hunger Goal will find its Sleep, Bath, and Wander Goals rise by a subtle amount. As a result, a component of Goal-Oriented Behavior further allows the Ghosts to examine the results of each Action when attempting to resolve any particular Goal.
In that regard, relating to the scenario in the adjacent image, the following example portrays a scenario where the AI in questions has a list of 4 available Actions. After a quick examination, it is evident that the Hunger Goal is the most prominent, so it would make sense that the AI chooses an Action that serves to reduce its Hunger Goal. However, there are two options present to fulfill Hunger: Order Pizza and Eat Snack.
A simple run-through of common sense would have us directed toward the Eat Snack Action, but how does the AI know how to choose this particular route? This is done by examining the process of time and discontentment. The time it takes to complete an Action may also lead to the rise of other Goal insistencies, and therefore could convince the AI to choose the latter option instead. However, in this case the AI only needs to refer to the discontentment result from both Actions.
The following provides a simple discontentment calculation for each of the 4 Actions.
Current Goal Status = ( 3 1 2)
Order Pizza: ( 3 1 2 ) + ( -10 +3 +4 ) = ( 0 4 6) = 10
Take Shower: ( 3 1 2 ) + ( +2 +2 -4 ) = ( 5 3 0 ) = 8
Nap on Couch: ( 3 1 2 ) + ( +1 -2 +1 ) = ( 4 0 3 ) = 7
Eat Snack: ( 3 1 2 ) + ( -4 +1 +1 ) = ( 0 2 3 ) = 5
Evidently, while both Order Pizza and Eat Snack reduce the Hunger Goal, the rise of Goal values from Order Pizza ranks it as a lesser option in comparison to Eat Snack. If the AI character's Hunger value was larger, Order Pizza may eventually be a better choice if the character can take advantage of the large Goal reduction rate.
While simple in its nature, the Spooky House application provides a basic study of Goal-Oriented Behavior and its utilization in Game AI, allowing for simple and efficient simulations to generate characters capable of believable decisions in the game world.