WMICraft/algorithms/genetic/map_generator.py
2022-06-02 00:52:16 +02:00

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.4
population = Population(mutation_rate, population_size, 27)
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()