A fun and easy way to learn about genetic algorithms by cracking a password.

Image for post
Image for post
EasyGA Python Package

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.

Here is all the code we will need.

import EasyGA
import random

Image for post
Image for post

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

# Print out the current generation and the population


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 =…


Daniel Wilczak

Dedicated college student who loves to write simple code for everyone. Passion to make machine learning for everyone.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store