Project Information

  • Language: C++
  • Graphics API: DirectX 11
  • Creation: Spring 2021
  • Source URL: GitHub Page

A.I. Behaviours

Created as part of my Artificial Intelligence in Games module, the task was to demonstrate various steering behaviours; seek, flee, arrive, pursuit, obstacle avoidance and wander. I was also required to demonstrate a path-finding behaviour, where the vehicle would construct a path from its current position to the next node along the racetrack using the A* algorithm without going off-road.

Examples of decision-making were also required, like where the vehicle should avoid obstacles, collect pickups, or slow down when turning a corner so that it will be able to complete the manoeuvre. A second dodge car was also required to demonstrate some of the aforementioned behaviours such as pursuit, where it would follow the original car around the racetrack.

What Did I Learn?

For this assignment, I learned a lot about the various steering behaviours and their implementations. I used a physics based system to demonstrate more gradual movements around the racetrack. As any given behaviour uses the physics system to apply a force in a given direction, this meant that most of the behaviours could be used simultaneously, with forces being applied from different directions resulting in a final direction which the car would then face. Some of the behaviours would need priority over others, however, as they would cause unnatural movements. Giving less priority to obstacle avoidance, for example, would mean that the car would make an attempt to avoid obstacles, but would just drive through them.

Using both the physics and AI systems, I was then able to implement all of the required behaviours regarding current implementations like in Mat Buckland's "Programming Game AI by Example," and Brian Schwab's "AI Game Engine Programming." Below is a list of all of the steering behaviours that I was able to implement using these systems that I had created.

Click the below to view a video of the behaviour in another tab.

  • Arrive
  • Decision-Making
  • Flee
  • Obstacle Avoidance
  • Path Following
  • Pursuit
  • Seek
  • Wander
To manage the change between behaviour states, I utilised a finite state machine - also demonstrated in Mat Buckland's "Programming Game AI by Example" - along with a toggle system that enables the user to toggle behaviours on and off at will. This enabled the use of ImGui windows, enabling the user to toggle between select behaviours, or enable multiple at once. Among these, the user can also select the path following behaviour which will cause the dodge car to move between each of the nodes placed throughout the track.

From implementing this behaviour, I learned about the A* algorithm, and how to it could be used alongside the physics system to create gradual movement between each of the nodes in the list.

Future Additions

Now that I have completed this assignment, I have learned a lot about implementing autonomous behaviours in a practical environment, where the result would have a noticeable effect on the physics of the vehicle. As for future additions, I would implement a range of different racetracks to further demonstrate the flexibility of the AI system that was implemented.

I would also allow the user to place their waypoints around the track. The dodge car would then use the path following behaviour to sequentially move between each of the nodes while avoiding obstacles, which could also be placed by the user, instead of just being randomly generated.


Feel free to drop a comment below.