Jump to content
  • Advertisement
Sign in to follow this  
aparaske

racing car AI

This topic is 4348 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, I want to experiment with neural networks and racing car AI. I'll be using an existing demo (everything prepared, graphics, physics, input etc) and i want to extend it by making the car to be controlled by a neural network. It would be difficult and time consuming to develop a tool to make sense of the track using the current area meshes. What methods would you suggest I use to overcome this? Someone suggested the use of splines. How could I implement splines for AI in this racing car demo? Alex

Share this post


Link to post
Share on other sites
Advertisement
You just have the designer/you lay down spline paths in your level editor. You read those in at runtime. boom - splines. Then give your little net inputs for distance away from spline.

brief conceptual tutorial for splines:
http://www.cse.unsw.edu.au/~lambert/splines/

also go to the Articles & Resources section. I believe there are a number of articles on racing games.

-me

Share this post


Link to post
Share on other sites
The benefit of the spline approach is that when expressed in parametric form, your splines are defined by a parametric velocity. The target vehicle velocity can be taken as a linear function of this parametric velocity, for situations where the vehicle is travelling along the spline. Where the vehicle deviates away from the spline, it can be given an additional forcing back toward the spline. Basically, you want a controller that minimises distance to the spline and matches velocity along the spline to that of the linear function of the parametric velocity.

Of course, dealing with other vehicles is slightly more problematic and the use of a single spline leads to poor quality visual appeal. I would suggest defining a set of splines for each track, relating to offensive, defensive and neutral approaches to that region of the track. Vehicles could switch splines according to what they want to achieve, or to avoid other vehicles.

Cheers,

Timkin

Share this post


Link to post
Share on other sites
I'm completely clueless when it comes to splines. The modeller used blender to create the track. I'm not sure how to add the splines. If anyone knows sites that give info on the following subjects please post them:
- Creating splines in blender
- Loading splines from file(coding)
- Using splines(coding)

Alex

Share this post


Link to post
Share on other sites
Creating splines in Blender is trivial. Blender homepage has some tutorials on the subject.

To load the splines, you will first have to write a Blender exporter script with Python. It is far more easier to do an exporter than to try to get the appropriate data from Blender's .blend files. Read Blender's manual for more information on the Python API, it should be very straightforward (it is for meshes at least).

Then you will have to load the splines into your application and handle them.

How realistic (read: complex) is the physics modelling of the game? The structure of the neural network will depend a lot on the physics model.

For a realistic game, you would have to look ahead of the track and calculate it's curvature (the "tightness" of the corner) and brake/accelerate accordingly. The steering wheel control should not be hard to implement. You should also pay attention to avoiding collisions and overtaking. IMO, it is more important to avoid collisions than to overtake. It is very frustrating for the player to be bumped out of the track by an idiot AI driver.

Btw, FANN (http://fann.sf.net/) looks like a nice library for neural networks, I have done some tests with the library and it worked quite nicely.

I saw an article on vehicle control with neural networks on the net somewhere. It concentraed on avoiding collisions only, but it seemed sane to me.

I would be very intrested to know what kind of project you are working on. Any homepage up yet? I am working on a racing game myself too.

-Riku

Share this post


Link to post
Share on other sites
Well, I think that instead of splines, I will create a number of checkpoints(one for every few "metres"). It would be much simpler in the sense that i wont have to get into new things, and i can achieve more or less the same. It would be interesting to learn how to use splines, build the exporter etc, but it might be better to avoid it for now since time is limited for this project(school deadline very near). The physics seem to be decent, even though it slides a lot(I heard that splines help overcome this problem, but the developer of the demo hasnt implemented them yet). I thought that it would be good to feed current state and previous state to the neural network so that it calculates the improvement of its actions at each step. That way, I wouldn't have to worry about the physics engine that much since the NNs would be able to improve themselves. It may cause a great overhead though this way since it would have to make up to twice the work to give an output. Perhaps instead of feeding the two state, i could feed their difference instead, and reduce the overhead of too many inputs. What do you think?

By the way, the demo is called motorsport. The website is http://www.motorsport-sim.org/

I havent worked on this project yet. The neural network AI extention is the first addition that I will contribute to the project.

Alex

Share this post


Link to post
Share on other sites
Ok, so you're really working on a simulator that strives to be realistic. I'd say you're pretty much in trouble :D Getting a decent AI for racing sims is far from trivial.

As I previously said, the curvature of the driving line is the key to good AI. If there is a curve ahead, the AI has to brake, if there's a long straight, then press the pedal to the metal. It is very important to look ahead, because once you're in the curve it's late to brake. You will have to carefully consider what inputs to give to the AI.

It might be a good idea to try to get training data and the racing lines from a real driver driving. It might be a good idea to drive around the track for 10-50 laps and save the replay data, analyze it and create training data from the replay data.

Live for Speed has a learning AI which I guess is based on neural networks. The AI's learning progress is very clearly visible, after 10 laps they are several seconds faster than on their first lap. You might want to ask the developers of LFS for a clue or two, but I'm quite sure you wont get any :( If you do, please let me know :D

BTW. The motorsport home page has been hacked by turkish hackers.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!