Jump to content
  • Advertisement
Sign in to follow this  
jakssdsfs

AI in a racing game?

This topic is 4610 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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!