it s alive, need to smooth fitness

This commit is contained in:
2019-10-23 16:58:09 +02:00
parent 8511af2e2c
commit bb115a95df
4 changed files with 18 additions and 12 deletions

View File

@@ -1,6 +1,7 @@
import numpy as np
import random
from brain import Neural_Network
from params import MUTATION_RATE
def genetic_selection(brains):
# tot_fitness = sum ([int(b.fitness) for b in brains])
@@ -36,7 +37,7 @@ def cross_mutate_genes(p1_gene, p2_gene):
else :
choice = p2_gene[idx]
# Mutation
if random.random() < 0.005 :
if random.random() < MUTATION_RATE :
choice[random.randint(0, len(choice) - 1)] = random.random()
print("Mutation !")
child.append(choice)