Search code examples
c++machine-learningneural-networkgenetic-algorithm

ai junkie neural networks tutorial - Not getting it


I've been trying to understand the neural networks tutorial at http://www.ai-junkie.com/ann/evolved/nnt1.html

I think I follow most of the tutorial up to page 8 (the last page), although maybe I don't because if I did, I'd probably understand the last page wouldn't I? Unfortunately for me, this page is not well explained because it should apparently be "easily understood from the comments within the code". And, the forum doesn't seem to work.

I guess I'm hoping for someone who has already seen or worked through this tutorial to help explain, but if you haven't and you'd like to take a look, go right ahead. Basically it combines a neural network and a genetic algorithm in order to control the left and right tracks of little tanks as they go around sweeping up mines. The neural network takes the position of the nearest mine and the direction(lookat) vector of the tank as inputs, and outputs the left and right tank tracks, which it uses to update the velocity and rotation of the tanks. At the end of a round, the tanks are bred to produce a new generation of better tanks.

But...I just don't get it. Specifically, I don't see exactly how the tank track values relate to the ability of the tank to pickup the mines, and I don't understand the difference between the rubbish tanks that don't pick up any mines and the good ones that sweep up mines quickly and efficiently.

Obviously(if you run the demo program) the tanks are improving the longer the simulation runs. But can someone explain to me (hopefully, to quote Tony Robinson, in terms that a Beano reader could understand) exactly what is going on?

Thanks!


Solution

  • Here is the best answer I can give, based on my interpretation of your question. Apologize if it is not what you were asking for, but you did ask for the most basic explanation.

    I don't see exactly how the tank track values relate to the ability of the tank to pickup the mines

    The way the tank works is that it has two tracks - left and right. Each of them has a speed. If both tracks are moving forward at full speed, the tank will move forward in a straight line. If the left track is moving forward and the right track is moving backward at the same speed, the tank will rotate clockwise. So it's basically a complicated control mechanism, designed to make the exercise more interesting than it would be if the tanks could take "move one square north" type instructions.

    The whole point of the neural net is to take the inputs (current tank direction and location of nearest mine) and generate outputs to correctly steer the tank with its wonky left/right tread controls towards the mine. The NN learns that if a mine is to its right, it needs to set left to "forward", right to "back" until it's pointed at the mine. Then it needs to set both left and right to "forward" so it actually moves forward towards the mine.

    I don't understand the difference between the rubbish tanks that don't pick up any mines and the good ones that sweep up mines quickly and efficiently.

    The rubbish tanks don't have the right NN to steer the tank correctly. If it sees a mine to its right, it might rotate left away from the mine because it doesn't "know" how to steer right. Or it might turn away from a mine it's already pointed at, rather than moving towards it. The good ones "know" how to move towards mines, which is to say that their NNs are weighted in such a way that when the input for the nearest mine is given, those NNs will tend to move towards the mine rather than away from it.