forked from s464965/WMICraft
27 lines
631 B
Python
27 lines
631 B
Python
from algorithms.genetic.genome import Genome
|
|
from algorithms.genetic.map_importer_exporter import export_map
|
|
from population import Population
|
|
|
|
|
|
def main() -> None:
|
|
population_size = 500
|
|
mutation_rate = 0.3
|
|
|
|
population = Population(mutation_rate, population_size, 55)
|
|
|
|
while not population.evaluate():
|
|
# create next generation
|
|
population.generate()
|
|
|
|
# calc fitness
|
|
population.calc_fitness()
|
|
|
|
print(population.best_genome.grid)
|
|
print("Fitness of the best: ", population.best_genome.fitness)
|
|
|
|
export_map(population.best_genome.grid)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|