Jump to content
  • Advertisement
Sign in to follow this  
NovaBlack

Racing Game AI (Crash course! - excuse the bad joke)

This topic is 3495 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

Hi guys!! Once again i am here to draw upon the infinite wistom that is the GameDev Community! Basically im trying to educate myself (in a period of around 10 days) in the fundamentals of racing game AI. i.e. bread and butter techniques, perhaps with a few tasty sprinkles scattered liberally over the top! I finished my degree this week (finally!) and start my job very soon, and was looking to ensure im down with the lingo when i get into the role. Anywho, i am already planning to read through the usual suspects (AI Wisdom 1 - 4 are lined up and ready!) (Interesting article in AI Wis 3 on adaptive PID steering controllers), and programming game ai by example has a nice section on steering behaviours. Anyhow, any input to keep me on the best racing line would be appreciated (its early.. im tired.. yes i make bad jokes), wether that be interesting article suggestions, book suggestions, names of commonly used techniques etc. Thanks guys (and gals) as always!

Share this post


Link to post
Share on other sites
Advertisement
* largest curve to fit within the turn is approximate the best line
* prefer a straighter exit line than straighter entering line
* being parallel to the line is aproximately good enough (dont need to be ON the line)
* the PID input should be forecasted based on speed.
* your speed should be based on curve radius and turn holding ability
* watch a ton of videos:
">Figure 8 racing
* an occupancy grid along the road may be used to create a virtual roadway, within which you can create your racing line to navigate through opponents.

But hey i didnt get hired for the last vehicle ai job i applied to, so i'm not gonna put much effort into this post. (out of spite :P)

Share this post


Link to post
Share on other sites
hahah no worries cheers for the first advice (if you do feel like the happy smiling face, and sparkling eager hope filled eyes of a newbie programmer, and a bag full of small fluffy kittens wash away your spite, feel free to post some more! lol)

Share this post


Link to post
Share on other sites
I implemented this really bad ass system. It was all designer placed pathing though. But you'd trigger it based on way points all these soldiers would drive up and skid to a stop in a blockade, jump out and start shooting at you. You'd kill em take one of their cars and drive off through another way point triggering another vehicle release which was a high speed chase.

Unfortunately it was only on my local test level, and then i got fired. That work was never commited or ever seen again. I got fired cause i have kind of a big mouth. :)

Best of luck to you, vehicles are my dream, keep me posted.

Share this post


Link to post
Share on other sites
Hi.

Heres the solution i used for my game game Auto Cross Racing.
You can try a free demo from the link below.

http://www.reflexive.com/AutocrossRacing.html


My technique was to use a waypoint system too.
A series of user created x,y positions along my race track which defined the best line for the ai cars to follow.

Along with the x,y position, was also stored a best speed at that waypoint variable.

so each waypoint consisted of ,x position , y position , speed variable.

Once i had created the best line with the way points, i then drove my player car around the track recording the best speeds for each waypoint.

Since my car physics were the same for the player car as well as the ai cars the stored speeds were applicable.

My ai cars, then simply drove from one waypoint to the next.
When an ai car came within range of it's target waypoint it moved onto the next in the list.

My code tested whether an ai car pointed either to the left or right of the waypoint and in the correct direction ( ie, the waypoint was infront of the car by some angle and not behind it ), my ai code then adjusted the steering of the car to bring it into line with it's desired waypoint.

That takes care of the steering of the ai cars.

As well as that, each ai car attempts to match it's speed to that of the speed defined in it's destination waypoint. This allows for ai cars to speed up on straits, slow down for corners ect and since i drove the fasted lap the physics would allow and recorded the speeds it was simply a case of modifying the speed values in each waypoint to change the difficulty levels of the ai cars.

Along with that.

I also added some code, that checked for closeness of the ai cars to each other and to take avoiding action.

Also code to drive the ai cars back on track if they left it, due to crashes ect as well as pitstop code and alternative paths.


Hope that helps

KJM

Share this post


Link to post
Share on other sites
Something else to look up: Flow fields - not just on the track but around individuals. There's an article about this in AIW4, I believe. Maybe 3.

Share this post


Link to post
Share on other sites
ahhh...

that flow fields idea sounds quite nice!
So for example, the track flowfield contining a field representing the best racing line, and small local flowfield around each car to use for overtaking / avoidance etc

hmm could do some intersting things with that!

e.g. dynamic obstacles (debris etc) having flowfields to use for obstacle avoidace. Even factor in some scaling based on relative speeds (ie. start going around an object earlier if for example it is stationary and AI is travelling at 100 mph, but smaller tighter flowfield around a stationary obj if AI travelling say at 5mph...

hmm... ill look up the article.. thanks!

Share this post


Link to post
Share on other sites
I've heard of people using the waypoint scheme in conjunction with a neural controller to give the cars more dynamic behavior. There is also various flocking and follow algorithms (see something like http://opensteer.sourceforge.net/) which can be used as well.

Good Luck!

-ddn

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!