Removed globals and fixed a few small print issues
This commit is contained in:
@ -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()
|
||||
|
||||
Reference in New Issue
Block a user