top of page
ryandwakeford

A New Personal Project - A GOAP Based A.I

Hello and welcome to this blog post. As a student of game development and a very enthusiastic and avid gamer, the mystery of a games A.I always intrigued me. The varieties of systems that I must have encountered during years of video game entertainment never seemed to be the same and always teased my curious side. I had always wondered how each system was implemented and why it was implemented the way it was. Many years and a university degree later, A.I systems in games is still a massive area of interest of mine, so I have decided to try and create one myself within the Unity Engine.

 

The Start

The Environment

Before I start designing and implementing the A.I system, I would need a simple environment that the A.I could reside and be tested. As I plan to implement a variety of test environment depending on the purpose of the A.I, I would need a simple hub or menu area where I could choose which test I wanted to run. Simply put, I wanted to create multiple scenes that would house a specific A.I test all linked via this hub area.


As I am not the greatest artist, my hub menu area will be a simple UI canvas with a table of buttons each loading a test scene when pressed. Accompanying the buttons will be a description of the test that the button links to.

Image 1: HUB layout.

Planning The System

As the title has stated, I plan on creating an A.I system that follows the principles of GOAP (Goal Oriented Action Planning).


The primary function of this style of system would be to allow the A.I agents (Non-player Characters) to feel like they are thinking about the world around them and the situation they are in. This might include anything between deciding to do the easiest tasks to complete their goal to actively reacting to world events such as threats.


To make the basis of this system work I will begin with a few scripts:

  • A script to store the game world's data to which the agent will react to (This should be a Singleton as there should only be one version of the world data).

  • A script to store the agent's data, which will be used to determine what actions to take.

  • A script to create an action plan using the given agents available actions. (I have planned for script to not inherit from MonoBehaviour).

  • A script to determine what is classified as an action.

I will also need two interfaces:

  • One so the agents are able to gain reference to the GOAP system itself to get the relevant data; and to produce its plan.

  • One for the actions to inherit the necessary functions needed to be a viable action for the GOAP system's logic.

Image 2: Simple Script Layout with Inheritance.

Script Design

After planning the simple structure of the GOAP system, which will likely develop and grow as I proceed, I now need to start planning the content of the scripts.


Some of the scripts will be simpler than others, so I shall start with the design of these.

Below is a table outlining the methods and variables I plan on adding to a couple of these scripts.


The names of these variables and methods are for identification purposes only, meaning that they are meant to be easy to read to understand what they are, not indicate what they will actually be called (var: = variable).

​Script Name

Methods/Variables

WorldData

var: factions

IAction

​var: prerequisites

var: effects

var: target

var: range check

var: weight

​var: complete

method: reset

method: check prerequisites

method: perform

method: requires in range

method: add prerequisite

method: remove prerequisite

method: add effect

method: remove effect


As this A.I system isn't going to be extremely complex to begin with, the only data the agents will need from the world is their relations to one another. I have decided to use factions as the term however, this could be adjusted to be teams for a single/multiplayer strategy game for example.


That is it for this post. Next time, I plan on creating these scripts and start planning the rest of the scripts needed to make this system functional.


As always, if you would like to stay up to date, be sure to check back regularly to see if there is any news or updates regarding this project!

0 views0 comments

Comments


bottom of page