diff --git a/src/Field.py b/src/Field.py index 89735257..65096105 100644 --- a/src/Field.py +++ b/src/Field.py @@ -84,5 +84,6 @@ TREE = 100 SHORT_VALUE = 1 TALL_VALUE = 100 -TREE_VALUE = 100 +TREE_VALUE = 200 +FLOWER_VALUE = 1 diff --git a/src/GeneticAlgorithm.py b/src/GeneticAlgorithm.py index d17d3c95..e2d491ec 100644 --- a/src/GeneticAlgorithm.py +++ b/src/GeneticAlgorithm.py @@ -154,8 +154,10 @@ class GA: def perform_mutation(self, individual): # Perform mutation operation on the individual index1 = random.randint(0, num_of_trees - 1) - index2 = random.randint(0, num_of_trees - 1) - individual.genes[index1], individual.genes[index2] = individual.genes[index2], individual.genes[index1] + new_x = random.randint(0, tilemapSizeX-1) + new_y = random.randint(0,tilemapSizeY) + if (new_x,new_y) not in individual.genes: + individual.genes[index1] = (new_x,new_y) def run(self): self.initialize_population()