Racing AI (with complications),
Members - Reputation: 1064
Posted 13 October 2005 - 10:03 AM
Posted 13 October 2005 - 10:37 AM
You can precalculate optimal paths this way, or you can have the AI take the decissions in real time, although I am not sure if this is practical.
For a racing game, I would imagine that the state can be described by:
* how far you are from the goal (or some other single-number indicator of where you are in the race),
* where you stand on the track in the left-right sense,
* what direction you are moving in,
* how fast you are going
and perhaps you need to add another number with the direction that the car is pointing to, since you have the "slide" option.
So if you consider 10 positions within the left-right range, 64 directions of movement, 16 speeds and maybe another 32 directions for where the car is looking at, for every "slice" of the racetrack you need 320K nodes. The good news is that you can start with the last slice of the racetrack (the goal), where you know exactly how long it's going to take you to the goal (0). Then computing the slice before that one is really easy. You keep going back like this, and it is always easy to find what the cost of getting from any node to the goal is, given that you know the cost of getting there from all the positions in front of you; just imagine you take each one of the actions and look up where you would end up on the next "turn".
This algorithm only requires keeping a few slices in memory at any given time (as many as can be traversed in a single turn at maximum speed). This is a lot of data, so in the end you will have to reduce it to something practical, like storing just one (or several) good paths.
I hope this helps.
Members - Reputation: 785
Posted 17 October 2005 - 02:51 PM
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.
Members - Reputation: 122
Posted 19 October 2005 - 09:07 PM
Moderators - Reputation: 4618
Posted 19 October 2005 - 09:25 PM
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! :)
Members - Reputation: 212
Posted 20 October 2005 - 08:23 AM
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:
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.