So let's say you've got a spline-based racing AI. Assume it can already handle the basics of braking and steering around the track.

How would you structure and implement collision avoidance, overtaking, drafting, blocking and other behaviours so your cars remain competitive but make interesting races?

Links to papers/implementations would be awesome.

  • \$\begingroup\$ what kind of engine you are using, \$\endgroup\$ – Harshal Benake Aug 18 '16 at 16:12

Have you seen Steering Behaviors For Autonomous Characters? I would consider a "CrowdPathFollowing" algorithm for staying on the track and avoiding collisions. You might be able to mix in a "Flow Field Following" behavior for drafting, passing and blocking - make the flow field follow the the player's past and projected path, but split around his current location.

 ----<  [playerCar]  >-----

That should cause the AI to tend to follow directly behind him and move directly in front to block, yet encourage clean passes.

| improve this answer | |
  • 1
    \$\begingroup\$ I'm aware of boids, but it's good reference. I'm a bit scared of many many behaviours (stay on racing line, avoid cars, block, draft, etc) interacting in ways that are too complex to tune, and ending up with the occasional edge case collision. This is fine for pedestrians, but catastrophic for race cars that need to keep moving. \$\endgroup\$ – tenpn Aug 5 '10 at 7:50
  • \$\begingroup\$ I've worked with the OpenSteer API which implements a lot of this stuff. I've found it pretty easy to tune. In your case I'd make the "SteerToAvoidCollision" weight very high. I don't know what vehicles you are racing, but I'd think that if you get it right for the vast majority of cases, then the remaining occasional bump or bash due to an edge case is probably pretty realistic.... \$\endgroup\$ – AShelly Aug 5 '10 at 23:07
  • \$\begingroup\$ Was that steering vehicles or something else? I'm scared of situations causing problems such as two vehicles ahead to your left and one ahead to your right. The average vector would result in a movement right, even though that might bring you into contact with the right-hand vehicle. \$\endgroup\$ – tenpn Aug 9 '10 at 13:04
  • \$\begingroup\$ I was working mostly with pedestrians, so I can't swear it will work. One thing to remember is it doesn't have to be a blend of behaviors - it can be a heirarchy. So you can have collision avoidance take a higher priority to anything else. In the case you describe the car would only go right until the predicted path intersected the right-hand car's path, at which time avoiding that collion becomes the overriding force. You can also add special conditions: for instance, if no safe path is found in N frames, add hard braking. \$\endgroup\$ – AShelly Aug 9 '10 at 22:57

There was a session partly about that at this year's AI Game Dev conference in Paris. You can find the slides and a summary here:


| improve this answer | |
  • 1
    \$\begingroup\$ The link to the ppt is 404. >_< \$\endgroup\$ – tenpn Jul 15 '10 at 12:04
  • \$\begingroup\$ @tenpn: It's a pptx: files.aigamedev.com/coverage/GAIC10_PaoloManinetti.pptx \$\endgroup\$ – Firas Assaad Jul 15 '10 at 13:29
  • \$\begingroup\$ ta -- his approach is interesting but the code I'm currently working with is actually more advanced! \$\endgroup\$ – tenpn Jul 16 '10 at 11:37

Anti-Pattern: Opponents adapting their speed

Unfortunately I'm not able to give You patterns, but I would like to name an anti pattern. Please do not try to adapt the speed of the AI drivers to the one of the human player. The idea behind this is to create fair racing conditions for amateurs as well as pros and to abandon the need of multiple difficulty levels (and their implementation).

However, what sounds good on paper turns out to be awful in practice and the MotoGP series failed miserably at implementing this behavior. It ended up in the opponents driving at 5mp/h when you stood still for a couple of seconds and the impossibility to tell whether you've improved in the game (very bad feedback wise)

| improve this answer | |
  • \$\begingroup\$ Thanks. I'm talking specifically about interesting race behaviours here rather than balancing or difficulty levels, but I'll bear it in mind. \$\endgroup\$ – tenpn Jul 15 '10 at 14:12
  • 5
    \$\begingroup\$ Nearly all racing games include some form of rubber-banding to keep the player in the action, or keep the AI close to good player. The trick is to be subtle with it and know when to turn it off. Once the player notices they feel cheated. \$\endgroup\$ – wkerslake Jul 15 '10 at 19:42
  • \$\begingroup\$ The MotoGP situation sounds like a problem of taking it too far, rather than a problem with rubber-banding in general. It is not unreasonable for drivers at the front to drive with more caution and cars at the back to try more desperately to close the gap, and I think there's value in modelling it that way and presenting that transparently to the player. \$\endgroup\$ – Jibb Smart Aug 19 '16 at 1:58
  • \$\begingroup\$ This is an interesting post on the topic: gamasutra.com/view/feature/3920/… Basically they put you in 3 groups of AI racers and let you advance from group to group during the course of the race. \$\endgroup\$ – Felsir Aug 19 '16 at 16:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.