#### Archived

This topic is now archived and is closed to further replies.

# Racing AI

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

## Recommended Posts

I've been programming a 3D racing game and have hit a snag: How do I get all the computer controlled oponents to find their way around a track consisting of polygons? How can I ensure that they don't blindly run into walls or eachother? How can I make them choose the fastest possible path (ie offroad driving). Any help would be greatly appreciated!

##### Share on other sites
Try drawing boundaries around the track and a line they are supposed to try to keep towards. If they are close enough to the line, then they are fine. If they are too far away, they try to move closer.

Then its like they are zipping around a hot wheels track.

Dont expect to be able to do it dynamically unless you want a MASSIVE search or to prerender everything like a PVS.

-Geoff

##### Share on other sites
Perhaps try seeding the track with points. The cars try to get from point to point, always heading for the next point in the right direction (make sure they don''t have to visit every point in sequence, otherwise they''ll irrationally backtrack if something goes wrong!). This''ll be enough for the first lap. Record the path of each car. On the next lap, have them try to find ways to cut corners, i.e. if there''s a kink in their previous path, see if that area is clear to drive straight from the two paths. And/or you can use a bit of random deviation to alter the path in various ways. The presence of other cars and their (I hope) attempts to avoid collisions with them will alter the path a bit too, so that may be enough randomness for you.

At the end of the second lap, compare the two paths and whichever one was fastest, go for that path into lap 3. Over lots of laps, the cars will (hopefully) become more efficient at getting around the course.

Alternatively you could measure the time between two markers that were crossed in both paths, and pick whichever the fastest was to build up a new path for lap 3. This will make your cars learn faster, as they don''t have to do well on an entire lap to learn how to take a single corner well, but could produce some difficulties if their paths become too sharp at points.

I''ve not tested this in a real game, although I''m contemplating a basic car racing game at the moment, which if it goes ahead will use this. Any comments/tips on this, anyone?

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 26
• 9
• 11
• 9
• 9
• ### Forum Statistics

• Total Topics
633716
• Total Posts
3013501
×