Animation: Smart Rockets

Smart rockets! Why are they smart? Because they use a genetic algorithm to learn the way to the moon over successive generations.

This is more interesting to watch on the full screen option - there's more space for the rockets to fly.

Each rocket is equipped with a main thruster that pushes them forward, and left and right thrusters that can rotate the craft. The idea is to find the way to the moon. This is quite difficult because the rockets have to fight against gravity.

When the rockets are created, they are given a list of instructions of when to fire which thruster. So for example this list of instructions might say Forward, Forward, Left, None, Forward, Right, Forward, None, Forward etc. This is randomly created, if you click "Reset", you will see that the first generation is pretty bad at flying.

At the end of each generation, each rocket's fitness is calculated based on how close they got to the moon. Without going too much into the maths - a genetic algorithm then picks out the fittest rockets and uses these to spawn the next generation. Over time the rockets as a group get fitter, which means they get closer to the moon. Eventually they will all be hitting or getting close to the moon.

This kind of genetic algorithm is a form of machine learning which is very powerful.

Read next