There are a lot of PC car racing games around which have this unique driving assist which helps brake your car so that you can safely turn it. While in some games it just an 'assist', it will just help your car brake but won't ensure a safe turn. While in others, the braking assist will help you get a safe turn. I was wondering on what could be the algorithm that is followed to achieve it.
A very basic algorithm I could think of was,
- Pre-determine the braking distance of an ideal car for every turn of the track, depending on the radius of the turn, and then start braking the car accordingly. For example, for a turn of less than 90o, the car would start braking automatically at 50m distance from the start of the turn.
A more advanced algorithm, which would ensure a safe turn, could be
- Pre-determine the speed of the car at the start of each turn, individually for each track, turn and car. Also, pre-determine the deceleration rate of each car individually, which varies because of the car's performance.
- The braking assist would keep recording the speed of the car at a certain instant of time.
- Start braking the car appropriately so that the car gets to the exact speed needed at the start of the turn.
- For example, let the speed of a particular car at the start of a turn 43m in radius, be 120km/h. Let the deceleration rate of the car be 200km/h2. If, at some instant of time, the speed of the car is 200km/h, then the car would automatically start braking at 400m from the start of the turn.