Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question

3 Answers 3

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.

share|improve this answer
1  
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. –  tenpn Aug 5 '10 at 7:50
    
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.... –  AShelly Aug 5 '10 at 23:07
    
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. –  tenpn Aug 9 '10 at 13:04
    
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. –  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:

http://aigamedev.com/open/coverage/paris10-report/#session9

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

share|improve this answer
    
Thanks. I'm talking specifically about interesting race behaviours here rather than balancing or difficulty levels, but I'll bear it in mind. –  tenpn Jul 15 '10 at 14:12
3  
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. –  wkerslake Jul 15 '10 at 19:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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