Racing AI - part 47Million

Started by
17 comments, last by Stevieboy 19 years ago
Quote:Original post by Shadx
It seems that your problem is not about the waypoints, but at the speed to which your AI are trying to take change waypoints at. Any chance you can provide information with hitting a way point? For example, you said that there was a straight away with a series of way point eventually going on a sharp turn, couldn't you provide information to the AI that when it's getting close to that turn that it needs to slow down or will miss the corner completely?

Basically, it's not just about reacting once your on a curve, but before you actually hit the curve.

Shadx


This is the problem, exactly. And sort of what I was asking, maybe I should have hit up the math&physics forum with a more specific inquiry.
I've gotten something half figured out that I need to mess with more. I take a series of 3 points ahead and fit a radius to them, then compare that radius to the minumum turn radius of the AI car at his current speed, and if he cant make it, he calculates a braking distance and such.
The problem is, depending on how the map's waypoints are layed out, this does not always work. Maybe I just need to look further ahead than three points? Does anyone know a way of finding the (average?) radius of a bezier curve?
Advertisement
CombatWombat,

I'm thinking something a bit different then "looking ahead". You do need to look ahead to interpolate the curve that you want your car to take, but I'm thinking that, a car, once achieving that way point, gets some info from it.

On a straight away lane, you would have
Waypoint 1 -> Give it all
Waypoint 2 -> Give er!
..
and once coming to a particular rough spot (big curve coming up in 4 way point let say)
Waypoint N -> Start reducing speed by 10
Waypoint N+1-> reducespeed by another 20
...

Note that when I say that the big curve is coming in 4 waypoints, I don't necessarily mean that you need to look ahead 4 waypoints, but when plotting those way points (making the AI path)you need to know that there's a sharp turn coming up ahead. You could automate all this using physics equations, but it's much more complicated...and over my head :) You can always start the easy way and improve on it later on.

Good luck,

Shadx
Quote:Original post by Shadx
CombatWombat,

I'm thinking something a bit different then "looking ahead". You do need to look ahead to interpolate the curve that you want your car to take, but I'm thinking that, a car, once achieving that way point, gets some info from it.


That's really not an option for a few reasons. It would be way too involved to repeatedly go back and forth between map editor and game testing to find the correct values to get the AI around the track quickly, but still safely. This is further complicated by the fact that all the AI cars are different, and may also have upgrades which makes them faster, turn differently, etc, meaning the values required for each AI driver would vary quite a bit.
This is a map editor which is built into the game for the USER to use, not just the developer. So fast and easy is a requirement.

Any indication of a turn would have to be interpereted geometrically simply from the positioning of the waypoints, and this is what I need suggestions on how to do most effectively.

Appreciate the help.
You change how far it looks ahead, so that when it is impossible to hit a corner, you can calculate the braking distance,ect.

From,
Nice coder
Click here to patch the mozilla IDN exploit, or click Here then type in Network.enableidn and set its value to false. Restart the browser for the patches to work.
Hi,

I guess my solution would handle all the braking and other problems you seem to have, would you mind telling me why you didn't even seem to consider it, as you didn't reply to it?

Thanks

Eric
Quote:Original post by xEricx
Hi,

I guess my solution would handle all the braking and other problems you seem to have, would you mind telling me why you didn't even seem to consider it, as you didn't reply to it?

Thanks

Eric


Your solution is pretty much what we've resorted to using, and thus far it looks like it may work. We have the steering bahavior setup to follow a line connecting each waypoint.

The logic of "ok we're going to look ahead and find a sharp turn" is perfectly sound. The trick is in the actual implementation. Angle from one waypoint to the next does not tell you the radius of the turn by itself. If you must turn 30 degrees to hit waypoint2 after waypoint1, its easier if wp2 is 500 miles in the distance than if it were 10 feet ahead, yes?

My current solution to finding the radius of turns based on a 3 waypoints ahead is mediocre at best and I dont really trust it in all situations. I need a better way to take N-number of waypoints ahead and analyze the path they create purely geometrically from the coordinates of them. Maybe fit some kind of curve to them and check the derivative of it to look for inflection points (would indicate a point between curves). The problem is I dont know enough of any type of curves (or calc for that matter) to actually pull that off.
As you go faster, you look further.

From positions + distances, you can work out what you need to stear. (pretty easily, atan2 (iirc) to get angle, then get the distance, and then figure out how much turn you need per unit of distance. (then you get how fast you are, to figure out how much turn you need per second).)

This is a molehill.
Getting this working for a lot of cars simultainiously is a mountain.

From,
Nice coder
Click here to patch the mozilla IDN exploit, or click Here then type in Network.enableidn and set its value to false. Restart the browser for the patches to work.
Quote:Original post by Nice Coder
As you go faster, you look further.

From positions + distances, you can work out what you need to stear. (pretty easily, atan2 (iirc) to get angle, then get the distance, and then figure out how much turn you need per unit of distance. (then you get how fast you are, to figure out how much turn you need per second).)

From,
Nice coder


The complicating factor is that our cars dont just "rotate" to turn. The car could slide out and generate alot of angular change per second, but this does not necessarily accelerate the car in a useful direction.

Although perhaps you are correct that I can use the angle between waypoints as well as the distance between them to describe the curve. Just a matter of working the exact forumlas to relate it to something the cars can understand.

I think I've got enough to go on for the time being. Thanks to all that yelled random things at me.
Could you not "shoot" a beam of some sort out in front of the car and find where that beams goes off the track? (umm this is hard lol). You have waypoints, so I don't know how you find the width of the track, -maybe a certain left and right "normal" distance either side of the way point, so between the way points if this beam goes out side of the track or edges (lines made between the left/right normals, coneecting the way points), at least you might know you are either getting to a turn or something. Maybe combine ths with the way points or something. I don't know how this would help with spins or anything though.

This topic is closed to new replies.

Advertisement