A fun and easy way to learn about genetic algorithms by cracking a password.
So lets get straight to it.
pip3 install EasyGA
Now you have access to the EasyGA package. If you’ve never used it before I would check out the wiki or the getting started with EasyGA article that was created. They use the popular game among us to explain some of the novice features. Now were going to try and crack the password: EasyGA. Yup the worst password ever but it proves the point here.
import EasyGA
import random#Create the Genetic Algorithm
ga = EasyGA.GA()password = input("""Please enter a word or sentence (Use only standard
characters such as letters, spaces and, punctuation marks)…
To keep my promise, here is all the code you will need to get your first genetic algorithm working with the EasyGA package.
pip3 install EasyGA
Run the code below in a python file anywhere on your computer.
import EasyGA
# Create the Genetic algorithm
ga = EasyGA.GA()
# Evolve the genetic algorithm until termination has been reached
ga.evolve()
# Print out the current generation and the population
ga.print_generation()
ga.print_population()
Output:
Current Generation : 15
Current population:
Chromosome - 0 [7][4][4][5][3][5][5][8][3][7] / Fitness = 3
Chromosome - 1 [7][4][4][5][3][5][5][8][3][7] / Fitness = 3
Chromosome - 2 [7][4][4][5][3][5][5][8][3][7] / Fitness = 3
Chromosome - 3 [7][4][4][5][3][5][5][8][3][7] / Fitness = 3
Chromosome - 4 [7][2][4][5][3][5][5][8][3][7] / Fitness = 3
Chromosome - 5 [7][2][4][5][3][5][5][8][3][7] / Fitness = 3
Chromosome - 6 [5][8][8][6][10][10][5][7][2][7] / Fitness = 2
Chromosome - 7 [5][8][8][6][10][10][5][7][2][7] / Fitness = 2
Chromosome - 8 [5][8][8][6][10][10][5][7][2][7] / Fitness = 2
Chromosome - 9 [7][2][8][10][3][5][5][8][1][7] / Fitness =…
About