# Genetic Algorithms – Getting A.I. to improve by itself

Computers are extremely powerful tools, able to calculate complex math and generate solutions in mere seconds. Couple this with giving the computer certain inputs that generate different outputs and we have a basic Artificial Intelligence (A.I.). However, even computers have their limits and can only process outcomes we predefine for them. But what if we gave the computer a problem and let it learn and create its own solution? (Don’t worry the Terminator outcome is still far from occurring).

Genetic Algorithms in programming mimic what we see in real-life evolution. It takes **survival of the fittest** quite literally. What the computer essentially does is generate *x* random solutions. From there it determines which solutions are the *fittest*. It then takes these fit solutions and *breeds* them together to create a new and hopefully better generation of solutions. The computer will continue to do this over and over again until it determines it has the fittest solution possible, or the evolution stagnates if the computer can’t find any better solutions.

In layman's terms, the computer mimics real-life evolution when solving a specific problem. Instead of taking thousands of years of evolutions, the computer with its fast processing power can take this down to a matter of minutes or even seconds. It’s important to note that the problem being solved needs a solution that can be measured (e.g. the shortest route between Point A and Point B).

Let’s take a more practical example. The traveling salesman is a problem where you have to find the shortest route possible when visiting *x* number of cities. However, the salesman can only visit each city once. What is the shortest route possible? Using Genetic algorithms, we can solve this problem fairly quickly. To begin with, the computer will generate random routes between all the cities (only visiting each one once). We can then **measure** the fitness of each route by how long the journey was. Take the shortest routes, blend them together to create more routes, and measure it all again. Rinse and repeat until you have the shortest route possible.

Genetic algorithms allow for the rapid trial and error of coming up with solutions to problems. This allows us to rapidly test different ideas and problems without having to go test each one by hand. This algorithm can be applied to a wide range of real-life problems. Allowing computers to calculate the shortest route possible between locations or to randomly design load-bearing bridges. Really, it’s up to the programmer how they use it to solve problems.

(A.I. learning how to walk using only joints and shapes)

However, couple this algorithm with other complex algorithms such as neural networks (mimicking how a brain functions) and you can actually create impressive A.I, that learns and gets better at doing certain tasks, not just solving problems. A great example of this is being able to create a creature from a random jumble of shapes and joints and getting it to learn how to walk.