Created
April 4, 2019 16:02
-
-
Save GypsyDangerous/4082256f2341ff4538a2f9682bcc21da to your computer and use it in GitHub Desktop.
GA created by davidsnyder1 - https://repl.it/@davidsnyder1/GA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import random | |
import math | |
def nextGeneration(population): | |
print('next generation') | |
size = len(population) | |
calculateFitness() | |
for i in range(size): | |
population[i] = pickOne(population) | |
def pickOne(population): | |
index = 0; | |
r = random(1); | |
while r > 0: | |
r = r - population[index].fitness; | |
index+=1 | |
index-=1 | |
bird = population[index]; | |
child = mitosis(bird) | |
return child |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment