Removed globals and fixed a few small print issues

This commit is contained in:
danielwilczak101
2020-09-24 22:47:12 -04:00
parent 45638ad4eb
commit 4daec6574d
3 changed files with 17 additions and 20 deletions

View File

@ -1,19 +1,20 @@
import random
import EasyGA
# Create the Genetic algorithm
ga = EasyGA.GA()
# Makes a new gene
new_gene = ga.make_gene("HelloWorld")
# Makes a chromosome to store genes in
new_chromosome = ga.make_chromosome()
# Makes a Population to store chromosomes in
new_population = ga.make_population()
#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)
# Creating population
ga.initialize()
ga.population.print_all()
print("")
print(ga.population.chromosomes[0].__repr__())
print(gene1)
print(chromosome)
print(populaiton)
populaiton.print_all()