• Advertisement
Sign in to follow this  

AI in a racing game?

This topic is 4343 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello.. I've been working on a projekt with some friends in DirectX9 and C++, we have very good structure (Scene Graph) and everything is very dynamic (and with own engine). But the area we don't have any experience in is AI and how to apply the AI to the racing opponents. We have right now a very simple path system that makes the opponent to travel against a position (on the map) and when it has arrived to continues to the next one. Very simple AI, but how can we make the opponents "smarter" and more advanced? Any suggestions?

Share this post


Link to post
Share on other sites
Advertisement
You could use a neural network to determine how much forward thrust or turning to apply. I'm doing some research in this area and have found some success

Nice thing about doing this is that you can train different networks to drive in different ways (ie. aggressive, careful, etc.) and so you can have opponents with different styles.

I'm doing it out of interest, I don't think it's really practical or necessary to use neural networks for games most of the time.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I think he is asking for racing strategies, not just pathfollowing methods.
high level stuff, how to pass another car, drafting, diving into the bottom of curves vs the outside, optimizing your speed based on the track, other stuff I can't even imagine, since I'm not a racecar driver...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
no clue, but the question prompted a google search and this came up as interesting

http://www.dummies.com/WileyCDA/Section/id-103572.html

Share this post


Link to post
Share on other sites
I don't think you need to much AI here.
Try a balance system this will take your car X and theres Y and when one is here the other is there

like this
Y = X*-1

You will need to change this to your setup. for this to work make 0 the center of the track and - will be off to the left and + will be right. It will make them do the oposite of what you do. If you want somthing better PM me and i will give you an AI code.

And if you need somthing like a drafing (when they stay behind you to reduce wind resistance) then use somthing like this to calculate drafting:
Yw = enemy car width
Xw = your car width
Yh = enemy car height
Xh = your car height
D = Inches to right
S = speed
A= Aceleration (must be set to start and output will be new aceleration)
(change x to set resistance level raising number will lower resistance)
X=100
Dw=Xy-Yw
Dh=Xh-Yh
Dv=Dh*Dw
Rv=Dv/2
Lv=Dv/2
Rv=Rv+D
Lv=Lv-D
V=Lv+Rv
R=S*V
A= A-(R/X)

Share this post


Link to post
Share on other sites
Yes, I was thinking of little more advanced than pathfinding (following nodes on map).

Your balance system sounds interesting, I will pm you for some little more information (as you said).

thanks for all the replies.

Share this post


Link to post
Share on other sites
what about it?
Right now I only have some nodes on a map and it interpolates a vector between the nodes, and the AI-cars are just going straight after that line (some delay when turning (depending on speed) which make it slide in turns), but it doesn't know how fast it should drive to stay on track, if I don't adjust in in the node manually. But I prefer not :)

That is all I got unfortunally, so I don't have any big clues how to do the rest.
Make the AI-cars figure out right speed in the curve/road, how it will react on impact with human-driver (if its just going to turn back to previous position as smooth as possible).

I can also tell that the game includes weapons on vehicle so that will also be a AI-issue but the driving is higher priority than weapons.
And that AI-cars don't just follow each other, that they will try to push out the other drivers of the road or just trying to get passed the leader.

All kind of AI is needed, all kind of help is helpfull.

Share this post


Link to post
Share on other sites
I meant depending on the complexity of your racing game, steering behaviors might be a very elegant solution.

I see only three steerings necessary:

a-Move forward
b-Avoid collision
c-Negociate Curve

-Move forward push your AI in doing loops the fastest possible
-Avoid collision make your AI avoid other cars
-Negociate curves make your AI brake to the right speed before entering curves.

I think each of these behaviors would be simple to implement.
a) is straightforward.
There is already tons of ressource on how to do b) in AI books/tutorials.
c) would be a simple calculation depending on the car velocity vector, projected position when entering the curve and the configuration of the curve.

Note that a) should push the car to take curve by the inside.

edit: ok I didnt read about the weapons. They can be added to the AI by adding more steering behaviors. Try to keep each of them simple, and it should work great.

Share this post


Link to post
Share on other sites
depending on the detail of your physics this may or may not work
but I may as well toss the 'PIT Manuever' out...
http://en.wikipedia.org/wiki/PIT_maneuver
basically it lets you force another car off the road...
might be fun to have as an AI behaviour, tho if every single car was trying it constantly things would get wierd...

Share this post


Link to post
Share on other sites
Great tips, thanks,

just one follow question to both of you.

You have any examples/sources of little more how the techniques work?

Steadtler, sounds like you have some experience in these things, I understand a bit of what you trying to say, but you know some source I can get more "hands on"-information?
Beacuse how it will move forward is very easy I agree, but avoid collision in a good way, I have no good experience about it so there I would like some more information if you got any, please.
(or where I can get the information I need)

great replys, thank you for the help

Share this post


Link to post
Share on other sites
Hum check out the book "Programming Game AI by Example" there is a good chapter on steering behavior including collision avoidance (with source!).

If not an option, Google "I feel lucky" gave this:

http://www.red3d.com/cwr/steer/

and it looks like a GREAT explanation.

check this out:

http://www.red3d.com/cwr/steer/PathFollow.html

hum... Im bookmarking that.

Share this post


Link to post
Share on other sites
Check this out

http://www.gamasutra.com/features/20051213/villiers_01.shtml

Share this post


Link to post
Share on other sites
I looked at PSO algorithm and "http://www.red3d.com/cwr/steer/PathFollow.html" and the "http://en.wikipedia.org/wiki/PIT_maneuver"...
The only problem is that all is theory, I understand a small part about how it should work, but don't really know how to "evalutate" things, they all say evaluate which node to goto and what to do, but I'm not sure how to evaluate the nodes, I know their position and can count where to turn but how to have best speed to take the turn the best and such things, that PSO and so should fix. Just want to see some code/functions/calculations how to evaluate the nodes to implement it.

anyone got some code/pseldo how it works?

Share this post


Link to post
Share on other sites
Quote:
Original post by Steadtler
Hum check out the book "Programming Game AI by Example" there is a good chapter on steering behavior including collision avoidance (with source!).

If not an option, Google "I feel lucky" gave this:

http://www.red3d.com/cwr/steer/

and it looks like a GREAT explanation.

check this out:

http://www.red3d.com/cwr/steer/PathFollow.html

hum... Im bookmarking that.


FYI the examples on that site look like a direct implementation from the book you mentioned

Share this post


Link to post
Share on other sites
Quote:
Original post by averisk

FYI the examples on that site look like a direct implementation from the book you mentioned


I dont think it is. The author of the site seems to have its own steering behavior library that predates the book.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Steadtler
http://www.red3d.com/cwr/steer/


This has to be the one site that is Always the first responce whenever anyone on gamedev has a question about moving any object to a path or goal.
And that makes me wary of it. Alternatives should be compared before blindly following the crowd.

I've looked through this guys algorithms and I have to say that they are mostly Animation pathfinding; they don't have a physics basis. A lot of his methods rely on 'ideal' vehicles that can change direction and velocity instantly. His algorithms are good a animating on object to look realistic, but there isn't an actual physics simulation operating in the background.
Consequently, I expect that if you go the other direction, and try to apply the algorithms to a realistic vehcicle, they will not perform as well because the physical limitations of the vehicle will prevent it from matching the changes requested in time.

For something like Racing Cars, I think you might need to delve into more robust methods, check into Control Theory.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement