WMICraft/algorithms/genetic/map_generator.py

27 lines
631 B
Python
Raw Normal View History

2022-06-02 00:52:16 +02:00
from algorithms.genetic.genome import Genome
from algorithms.genetic.map_importer_exporter import export_map
from population import Population
2022-05-29 23:13:45 +02:00
def main() -> None:
2022-06-02 00:52:16 +02:00
population_size = 500
mutation_rate = 0.3
2022-06-02 00:52:16 +02:00
2022-06-06 14:59:24 +02:00
population = Population(mutation_rate, population_size, 55)
2022-06-02 00:52:16 +02:00
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)
2022-05-29 23:13:45 +02:00
if __name__ == '__main__':
main()