# How does braking assist of car racing games work?

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

1. 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.
2. The braking assist would keep recording the speed of the car at a certain instant of time.
3. Start braking the car appropriately so that the car gets to the exact speed needed at the start of the turn.
4. 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.
-

## migrated from superuser.comDec 20 '12 at 6:36

This question came from our site for computer enthusiasts and power users.

More sophisticated options would factor in the weather, road surface, weight distribution of the car, characteristics of the suspension and tires. I've seen games like Real Racing 2 where upgrade options modify suspension and tyres and some others allow suspension tuning. A game with persistent world characteristics could take into account accumulated crap on the road and changing wear and stiffness of tires as they warm up. – Andy Dent Dec 20 '12 at 6:28
[it seems I cant comment yet, so I post this as an answer] In addition to the second of Your proposals I would tweak this algorithm to brake slightly too much so that the speed at the beginning of the turn is lower than the optimal speed. The intention here is that player should discover that he can take the turn faster without going out of track if he don't use the assist. I'd like to encourage player to disable assists which should make him more proud of himself. – Grzegorz Sławecki Dec 20 '12 at 9:58
Would any algorithm here be noticeably different than controlling an AI opponent? – tugs Dec 20 '12 at 18:10
Not noticeably, but yes, different in many aspects. You can make AI move at any speeds and angle and still make a normalized movement impression. In this case, an AI character can turn even at the speeds of 160km/h, even if its not possible, but the first algorithm here wouldn't allow a player to do that. Even for the second one, the role of the assist is to get the car to the optimum speed required at the start of the turn. If a player plans on increasing his speed thereafter, he won't be able to turn. – Ayush Khemka Dec 22 '12 at 9:37