How AI Works: Genetic Algorithms Part 1

How Artificial Intelligence Works

Part 1: Genetic Algorithms


Darwinia
Hi Steemit. So as I've said before, I'm really big into programming. While I was thinking of topics to write about for today, I remembered how much I struggled with learning about artificial intelligence, neural networks, fitness functions, and how all of it worked. So I decided to myself that I should make a simple tutorial on AI.

Quick Warning: I'm by no means an expert, all my info comes from MIT Open Course ware Lectures, my own brain, and random stuff I've read on the internet.

Evolution

So if you took Biology in high school, you're probably aware of evolution. It's based on three principles:

  • Organisms have different traits
  • Some traits do better than others in certain environments
  • Traits pass down from generation to generation
  • (Traits have a slight chance of mutation)

By themselves, or when one of these are missing, evolution simply can't happen. For example, even if organisms have different traits, and those traits pass down genetically, if all the traits are the same then no evolution can take place. Try it yourself, take out any part of those three aspects and nothing will change.

Now you may have noticed that despite me saying there's three aspects to evolution, theres a 4th bullet point that addresses mutation. Mutation isn't strictly necessary for evolution to occur, but without it then the neural network is limited by how much it grows. For example, monkeys who mated together, without mutation, would have never formed humans without mutation, since it's mutation that brought large brains, less fur, and bipedal movement.

Applying evolution to computers

Now let's say you want an AI that's really good at playing a game, say, Mario. You could start by making 1,000 versions of Mario, with different brains and algorithms generated randomly (this will be explained further in Part 2). You have all of the algorithms play the game, and see which one does the best (gets the farthest in the farthest amount of time). The ones that do the best are allowed to 'reproduce" (have their algorithms mix with those who did the best, while the worst are discarded. The second generation begins, with some being randomly generated, some being slightly mutated offspring, and some being the original, and the cycle continues for as long as necessary, hundreds or even thousands of generations, until an algorithm appears that is very, very good at what it does.

Normally, evolution would take hundreds of thousands of years for even slight improvements. However, computer generations can be as fast as the computer can allow, allowing for hundreds of thousands of generations in a few hours.

Now this is a pretty simplified version of how this works. You probably have several questions, like, how does the AI know what the goal is? I've heard of supervised and unsupervised learning, what are those? How do AI think? All of these questions and more will be answered in later posts.

Thanks for reading this, if you have any questions, suggestions, or criticisms, please feel free to let me know.

Sources:
https://en.wikipedia.org/wiki/Genetic_algorithmv
https://www.mathworks.com/help/gads/what-is-the-genetic-algorithm.html
All of CodeBullet's videos

H2
H3
H4
3 columns
2 columns
1 column
3 Comments
Ecency