Skip to content

Instantly share code, notes, and snippets.

View ShaulSolomon's full-sized avatar

Shaul Solomon ShaulSolomon

View GitHub Profile
@ShaulSolomon
ShaulSolomon / helloevolve.py
Created February 6, 2018 07:18 — forked from josephmisiti/helloevolve.py
helloevolve.py - a simple genetic algorithm in Python
"""
helloevolve.py implements a genetic algorithm that starts with a base
population of randomly generated strings, iterates over a certain number of
generations while implementing 'natural selection', and prints out the most fit
string.
The parameters of the simulation can be changed by modifying one of the many
global variables. To change the "most fit" string, modify OPTIMAL. POP_SIZE
controls the size of each generation, and GENERATIONS is the amount of
generations that the simulation will loop through before returning the fittest