# How do genetic algorithms work exactly?

I was looking at the basic genetic algorithm here

http://www.ai-junkie.com/ga/intro/gat1.html

But I have some questions about things I didn't get.

To reiterate:

You have a problem you want a good enough solution to.

You create N random solutions (encoded as bits of 0 and 1)

You evaluate a fitness or score for each for how good a solution it is.

Pick randomly 2 different of them. Based on each score, they have a higher chance of being picked. (i.e. higher score = higher chance of being picked, but the sum of all probabilities add to 100%)

Then for those 2 (call it A and B) picked, there is a cross over step. There is a chance associated with a crossover. The link uses 70%. So if the crossover happens, then we pick a random point and exchange the bits of both A and B after the point. This creates C.

1. We created a new solution. Do we remove one of the existing ones? If so, which one?

Then there is a mutation step. This is the part that confuses me most.

1. Does mutation step occur regardless of if the crossover step happened or not?

2. What do we mutate? A or B or C?

3. For whatever we mutate, does mutate mean we iterate over each bit, and for each bit there is a 0.1% chance to flip the bit?

Finally reevaluate the score for all and repeat all of this until you find a good enough solution.

Does anyone know?