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.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)
|
2022-05-29 23:13:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|