Skip to main content
GameDev.net gamedev.net
🔒 Locked

Racing AI (with complications)

Started by Drilian Oct 13, 2005 at 4:03 PM 7 replies 10.2k views
Original Post
Drilian
Drilian
Having read through some of the other racing AI threads on these forums, I've noticed that most of them involve creating an AI that follows a developer-specified optimal racing line. But my tracks are hideously loopy: My Journal, for Screenshots. I really would rather not have to manually create a racing line for each track. Mostly because I don't even know that I could FIND an ideal sort of racing line. Heck, I'm not even sure that, as bad as I actually am at racing games (don't let the fact that I'm writing one fool you), I could even DRIVE a fairly optimal line. And another wrinkle: In addition to the steering and the accelerator (which includes the brakes), there's also a "slide" button, which turns off the motion dampening in the car's sideways movement (i.e. holding "slide" allows the car to continue moving in the direction it's going, even if the car turns). I'd like the AI to be able to use that feature, though I won't be terribly heartbroken if it can't. Is there any other sort of way to generate a near-optimal racing line? Or to make an AI that can use other attributes of the track to drive such a track? Suggestions? I'm new to this whole AI business, so it could be (And is even likely) that I'm missing something horrendously obvious. Please feel free to point it out. Thanks much, Josh
databandit
databandit
First, you could use an algorithm (I prefer A*) to find sort out the path, and then do something like this: "if the angle of turn is more then n degrees, then enable 'slide' feature"...

-zubair-
PS: sorry if i was too brief
Amps
spookycat
spookycat
Grab a copy of Ai Game Programming Wisdom 2, theres an article in there on Generating Racing Lines automatically. Page 485
Drilian
Drilian
Thanks for the help, everyone!

A copy of AI Game Programming Wisdom 2 is on order :D
Rixter
Rixter
While waiting for your book check out RARS and some of the cars people have done for that (may need to google for them, look for K1999 by Remi Coulom for a really awesome car, can't find the paper right now though).

Under algorithms you can see how someone used A* for it.

Here is a reinforcement learning example for RARS. Also check into neural-nets, which I hear worked quite well for Colin McCrae Rally.
Ande
Ande
About that sliding thing, I recently implemented AI players in my top-down racing game Turbo Sliders. As the name suggests, sliding is an integral part of the game and it surely did add complexity to the AI code. AI cars try to follow one of 10-20 racing lines (generated by human driving) but it was quite hard to make it work with the cars that slide a lot. Are you aware of other racing games with AI where there would be as much sliding?
Kylotan
Kylotan
Drilian, I would be tempted to just hand each track to a bunch of playtesters and record the paths they take, recording how they use the controls and possibly tweaking them slightly, to be used later by AI controlled characters. It might also be worth seeing how far you can go (literally) with simple steering behaviours.

And bear in mind that, relative to the track itself, the racing line is still just 2D (assuming I understand your game). The problem is easier to think about in those terms, as I believe the AI Wisdom article will cover.

PS. Ande, I love Turbo Sliders. Great game! :)
me22
me22
I was skimming your journal and noticed:

Quote:
Original post by Drilian
Plus, the car has a force-field (or whatever they will call those things in the future), so the walls actually bounce the car more like a pinball bumper than in a realistic fashion (the force field applies some bounce force).


Combind that with sliding, and a perfect AI might end up finding some very unlikey--but very fast--ways of bouncing through corners, which you might not actually even want.

You also mention:
Quote:
Original post by Drilian
Each track segment gets the following attributes (which are relative to the track segment's initial orientation):
Length - This represents the angle of the track relative to the in-game representation of the north star. That, or just the length of the track down the middle. I can never remember which is which.
Width - Determines what the width will be by the end of the section of track (the previous section determines the initial width).
Curve - The amount of curvature of the track. A negative curve is to the left, positive is to the right. A 360 degree curve is, as expected, a full rotation.
Horizontal Skew - This is how much the track strafes to the side (along a sinusoidal sort of path) across its length. It's like a lane-change. Only the pavement is changing lanes, not the car.
Incline Curve - This is the circular incline of the track. A 360 degree value of this would be a full loop. Positive is up, negative is down.
Vertical Skew - Similar to the horizontal skew, only vertical. How's THAT for descriptive?
Twist - This is how much the track rolls to one side or the other along its length, which modifies the orientation for the next segment
Bank - This is similar to twist, except it raises one side instead of twisting around the middle, and the orientation remains unchanged in the next segment of track (this is to allow for banked curves, which I wouldn't want to curve upwards because of the bank or something stupid like that).


You might be able to use an abstraction of those for the current and next segment as inputs to a neural network. Alternatively, some sort of FuSM might also work, although the outputs aren't all that orthogonal, so it isn't the greatest place for a FuSM.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.