This commit is contained in:
danielwilczak101
2020-09-24 23:51:40 -04:00
parent 4daec6574d
commit 78d63aa4aa
2 changed files with 26 additions and 14 deletions

View File

@ -1,20 +1,16 @@
import EasyGA
import random
# Create the Genetic algorithm
ga = EasyGA.GA()
#Creating a gene with no fitness
gene1 = ga.make_gene("Im a gene")
gene2 = ga.make_gene("Im also a gene")
#Creating a Chromosome with no genes
chromosome = ga.make_chromosome()
chromosome.add_gene(gene1)
chromosome.add_gene(gene2)
# Creating a populaiton
populaiton = ga.make_population()
populaiton.add_chromosome(chromosome)
def user_defined_gene():
return random.choice(["left","right","up","down"])
print(gene1)
print(chromosome)
print(populaiton)
populaiton.print_all()
ga.gene_function_impl = user_defined_gene
# Creating population
ga.initialize()
# Print the current population
ga.population.print_all()