Over the past 5 weeks, I’ve been working on a Creature Feature project which requires me to procedurally generate a world for a chosen creature to roam around in and behave appropriately. There were many challenges that I faced throughout the project and major games programming concepts that will be discussed here in this post-mortem. The three main programming concepts covered in the creature feature project was procedural generation, pathfinding, and AI behaviours.
Procedural Generation
A requirement for the project was to procedurally generate an environment and objects within that environment for the creature to interact with. For this problem I used Perlin noise to generate a terrain height map, I chose this because Perlin noise has been used in industry to procedurally generate in-game items and it is good to know. From this a mesh asset was created and depending on the height of the mesh vertex it was coloured and instantiated as a particular object. The lowest point of the mesh was water, the water then transitioned to sand, it then transitioned to grass and finally, the top of the mountains were instantiated as snow. On each vertex and I also generate either a tree or a bush if the Perlin noise of that vertex is above a certain decimal, this is also only calculated at heights that are at the grass height or above. This created a consistent random number of trees and bushes into the world.
This method that I used was extremely efficient and very simple, it fulfilled all of the requirements that were mentioned and successfully generated a world for the creature to roam around in. There are however a number of limitations, these were that water had to always be located in the valleys and snow at the top of the mountains, this has very low variability and customisation. For future projects, I now understand how to utilise Perlin noise to generate gameobjects and a height map and I will be able to use it to procedurally generate an environment.

Pathfinding
There are three main aspects of pathfinding that are needed to be implemented in order to successfully create a pathfinding system. That is world data, pathfinding algorithm and steering.
World data is all about converting information about the world space into data that can easily be processed by the pathfinding algorithm. For this project, I used a grid node based system which is created and recorded when generating the mesh vertices, which records the location of the node and the type of node it is (water or land). This system has a number of pros and cons, the pros are that its an extremely simple system that is very cheap and a con is that the movement of the AI then feels very fixed, only being able to move in diagonal and simple directions. Another alternative to this system could be to use navigational meshes which generate nodes depending on the areas of the world which could have suited well with the vertices that are generated. For the future, however, I have learnt a simple method of generating world data which is extremely useful in a grid or tile-based world.
The pathfinding algorithm is the main part of the pathfinding system, there are many different algorithms to implement but I used the A* pathfinding algorithm. This algorithm is considered a guided search which takes into consideration the distance between the current node and the destination node when generating the path. This algorithm has been used as an industry standard because of its efficiency and worked extremely well in the project, even when it was being calculated on every update the project was still able to run relatively smoothly. In the future, I’ll be able to efficiently pathfind around the world, I’ve already begun implementing it into my other projects IRNTJ where a lion is chasing the player.

The final aspect of pathfinding is steering, after processing the node path from the pathfinding algorithm the agent must make their way through the world and avoid obstacles. There were 2 measures that I took to ensure obstacle avoidance, the first was to ensure that a random offset was created by each spawn to ensure that a tree or bush did not spawn on a node. The other was to implement potential fields to each of the obstacles and that they were triggered when the agent enters a trigger box. Potential fields give a repulsive force depending on the distance an entity is from another entity, the closer they get together the stronger a force is given. Using both these techniques gives me a simple and effective way to avoid obstacles within a world for future projects.

AI Behaviours – GOAP
GOAP is an AI system that gives your agents choices and the tools to make smart decisions without having to maintain a large and complex finite state machine. Finite state machines have different states for the Agent such as Idle, Attack and Block and calculates the agents actions depending on the state that they are currently in, this may get complicated and cumbersome.
Goals – This is something that the agent is trying to achieve, the agent then attempts to build a list of actions to complete the goal.
Actions – an action is something that the agent does, to help determine what actions the agent wants to use, each action is given a cost. A high-cost action will not be chosen over a lower cost action. The actions are collected into a sequence and the costs are added up.
How GOAP is used:
- The GOAP system has a GOAL state that it wants to achieve such as “GET FOOD” and underneath that goal there are a number of actions that are assigned to completing that goal.
- These actions have preconditions assigned to them meaning that there are a list of checkboxes that need to be fulfilled in order for them to perform the action.
- Additionally, each action has a cost, the more costly the action it the less efficient it is to do that action. The AI then chooses the actions with the smallest cost.
- Example: ‘Hunt’ Preconditions – has weapon, is in range of food source
- Get Weapon has cost of 1
- Hunt has cost of 6
- Gathering Berries has cost of 10
- Furthermore, the benefit of the action is taken into account when considering which action is taken. (i.e. how much food is gathered by the action)
- Once actions have been determined, the actions are then pushed onto an Action stack where the AI commences and completes the actions within the stack.
There are pros and cons for this AI behavioural system, each Action is able to be tested and added individually. It allows for actions to be shareable fairly easily and adding goals for the actions are then also fairly simple. The con for this system is that the startup cost for implementing the system was fairly expensive and probably shouldn’t be used for smaller projects. However I now know how to implement a behavioural system for an agent, after the initial implementation of the system it was easy to alter goals and actions to suit the game.
Overall, the project was extremely successful I learnt many essential games programming techniques and different possible implementations. The project was extremely challenging but creating the systems was useful from a functional standpoint and educational standpoint, these techniques will definitely be used in the future.

Leave a reply to Studio 2 Presentation – Me, My Blog and I Cancel reply