fix monsters count in fitness func;

This commit is contained in:
Angelika Iskra 2022-06-06 14:59:24 +02:00
parent 3f68f4c8a6
commit 6ddfddb2fd
6 changed files with 4 additions and 4 deletions

View File

@ -81,7 +81,7 @@ class Genome:
sands, trees, waters, monsters = get_tiles_positions(self.grid) sands, trees, waters, monsters = get_tiles_positions(self.grid)
if len(monsters) < MONSTERS_COUNT: if len(monsters) != MONSTERS_COUNT:
self.fitness = 0 self.fitness = 0
return return

View File

@ -7,7 +7,7 @@ def main() -> None:
population_size = 500 population_size = 500
mutation_rate = 0.3 mutation_rate = 0.3
population = Population(mutation_rate, population_size, 60) population = Population(mutation_rate, population_size, 55)
while not population.evaluate(): while not population.evaluate():
# create next generation # create next generation

View File

@ -1 +0,0 @@
{"map": [[3, 3, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0], [0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 2, 0, 0, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 2, 3, 3, 3, 3, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 3, 0, 0, 0], [0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 0, 1, 2, 0, 0, 0, 2, 0, 0, 0, 0], [6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 3, 3, 3, 0, 0, 0, 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