Managing race difficulty using a rubber-banding system
We usually want to create experiences that adapt to the player, and racing games are a good field for this, given that there is this gap of the cheater agent.
In this case, we will explore a middle ground for this using a framework that allows you to come up with your own heuristic for managing the speed of the vehicle given its status. It doesn't matter if it is an arcade racing game or simulation; the framework aims to work in a similar fashion for both the cases.
Getting ready
It is important to have grasped the basic skills in Chapter 1, Movement, in order to be able to develop a strategy to extend the framework for your own needs—that is, understanding the principles of how the agent class works and how the behaviors help the player move toward an object. In a nutshell, we are talking about vector operations.
How to do it...
We will implement three different classes for handling low-level and high-level AIs as follows:
Create the class...