   Car Control with Neural Networks
  So, hi. First post. My mind is fried and I'm getting nowhere fast.As part of my project in uni (which has to be in on Wednesday) I need to make a car travel around a track utilizing neural networks. I have a working scene and a working network. The network trains sufficiently and I can pass my own varibles into the network so they are fed through correctly.My problem lies in trying to get a relevant figure out to effect the variables correctly. As mentioned, my mind is fried and I have no idea how a network that is producing a 0.0 to 1.0 figure is supposed to adjust the angle and X & Y speed of the car.I figured it'd be best to feed data through the net once per variable that needs adjusting, but no idea if I'm getting correct figures out, and how to apply them if so. I'll post a code sample below. Please try and keep the coding/NN speak light, as mentioned: brain = fried.FYI: the track is a simple square/loop with four corners. Because I'm awkward, it's going anti-clockwise. The screen ranges from +1.0 top right, to -1.0 bottom left.Calling the network in main:value = link->netMain(rotateCar, myCar.x, myCar.y, myCar.speedX, myCar.speedY, keys[currentPt].x, keys[currentPt].y, 2);rotateCar is the angle of rotation on the car.myCar.x/y are the X & Y co-ords of the car.myCar.speedX/Y are supposed to vary as to give the illusion of speed by how much the distance the distance is effected per frame.keys[currentPt].x/y is the current key point/corner.The last input is supposed to relate to which variable is going to be adjusted on that feed-through (ie. 1 = rotation, 2 = X value etc.)Network:float testData[7]={rotateCar, carX, carY, speedX, speedY, ptX, ptY};bp->ffwd(testData);return bp->Out(0);The inputs from main are passed into testData[].The data is fed through using bp->ffwd(testData).MSE from network can be returned using bp->Out(0);I hope this helps, and thus I hope you guys can help me. If this doesn't aid you, I can try and post my complete project file.EDIT: I have uploaded my project file as a .rar, size is 9MB. I apolgise for the probable messiness too, as you can imagine I've just been testing almost everything out.http://www.mediafire.com/?qoctjgrkvmz[Edited by - NewDamage25 on April 17, 2010 12:09:47 PM]
  Are you having a problem with your representation or your data?  Given your "exotic" representation you'll probably have to create a bunch of examples manually and feed them into the network for training...The "typical" way is to have a bunch of distance sensors and possibly a relative position of the race line as inputs, and use the output to steer, accelerate or break.What part in particular is frying your brain?   ;  Thanks for the reply.as I mentioned, the training of the network appears to be going fine. I manually set up training data which gives say at a given X & Y, the X/Y speed should be this, the angle should be this etc.My main concern is how I'm supposed to get back and apply  figures from the network to adjust the angle/speed of X/Y.By just using the MSE that is returned and correlating that to the X & Y co-ords obviously just results in the car jumping around illogically, which I understand.Its the fact that I'm unaware how to get out a particular figure for the X or Y or rotation and adjust that one variable accordingly. And obviously given that the course is a loop I can't just + or - the result all the way around.I will upload my solution to the original post.It's in C++ & using OpenGL for GFX, using Visual Studio.   ;  Gamedev.net has an excellent article on vehicle control with neural networks.Have you seen it yet?  It is here:http://www.gamedev.net/reference/articles/article1988.aspThe idea is you use a 3 float array to represent the left,center, right relative distance of anything in front of the car.  This is the input.  It also explains how the output can be used to derive the acceleration and steering angle of the car.   ;  Is the use of neural networks an absolute requirement?  It seems like a square peg rammed into a very round hole.  One of Craig Reynold's steering behaviors, or (if you wanted to be more sophisticated) a potential-function or Voronoi-based approach would be a much better fit, honestly.If it's important that you be doing "learning," then I'd say Q-learning could be appropriate.   ;  Sadly, yes, the use of NN is the most important part.Its for my final year project in uni, which was started back in September and is due on April the 21st. If it was just the coding I could probably justify changing methods, but we've had to produce a report on the subject too, starting with research in our chosen topic, then development etc.   ;  Look into steering behaviors, boids and craig reynold's work.  You need a model like that (e.g. turn, speed actions) before you can plug in your neural network.I'm also a little surprised you were able to train your NN without having figured out the exact outputs.  It seems like the wrong way to go.  How do you know your NN is giving you the right control values?If you do things right, you can just take the NN's output, scale it a bit, and control your vehicle directly.   ;Quote:Original post by NewDamage25Sadly, yes, the use of NN is the most important part.Please tell me that they aren't pitching this as being relevant to game AI.;  Thanks to the guys who have helped thus far.I believe I have somewhat made a little progress. Using your suggests I've been able to take the MSE output (the 0-1) figure and rescale how I need it (eg. between 0 & 0.03) and apply it to my X & Y change co-ords. The speed does somewhat change.I've done the same for the angle, scaling it so that it can only change between -5 & +5. But it seems to always give out a figure of around -5. And by applying it to the car's rotation means it rotates backwards (I want to go anti-clockwise) and constantly.I set it up, in a rather cheating manner, so that the car basically in a diamond path from the middle of the X to the middle of the Y axis, just for testing.This kinda brings me back to one of my original problems. Say I'm in line with the first point and want to head straight towards it, how can I ensure that only the X axis is effected, as opposed to Y & rotation at the same time.   ;  If I am not mistaken you have trained a nn that can perform a function like this:x,y -> vel_x, vel_y, angleThis should work in principle if you're using correct training data, i.e. a big two-dimensional array containing the correct values. Surely a nn can learn this, but this kind of representation seems rather strange to me.If this is really what you want to do, all you need is to check each car for its current x/y speed and angle, compare that to the reference value from the nn-output and apply correction. If this doesn't work it either means that your nn hasn't converged, not complex enough or that something is wrong with the training data.best wishes   