From 80c72f1ba0153e00afeb8aeeb5f7dcd9a91e03fa Mon Sep 17 00:00:00 2001 From: Mateusz Date: Wed, 27 May 2020 00:23:56 +0200 Subject: [PATCH] method that return travel as correct list work --- src/AI/GaTravelingForHerbs/GeneticAlgorithm.py | 8 +++++++- src/game/Game.py | 7 +++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/AI/GaTravelingForHerbs/GeneticAlgorithm.py b/src/AI/GaTravelingForHerbs/GeneticAlgorithm.py index 31bab59..bdd2c2f 100644 --- a/src/AI/GaTravelingForHerbs/GeneticAlgorithm.py +++ b/src/AI/GaTravelingForHerbs/GeneticAlgorithm.py @@ -33,6 +33,12 @@ class GeneticAlgorithm: i += 1 if self.stopCondition(i): - return theBestMatch + return str(theBestMatch) + + + def listOfTravel(self): + strTravel = self.run() + import ast + return ast.literal_eval(strTravel) diff --git a/src/game/Game.py b/src/game/Game.py index 566fe08..a5be113 100644 --- a/src/game/Game.py +++ b/src/game/Game.py @@ -421,13 +421,12 @@ class Game: mutationProbability = float(0.1) ga = GeneticAlgorithm(firstGeneration, mutationProbability) - movementList = ga.run() + movementList = ga.listOfTravel() print(movementList) + print(type(movementList)) + print(movementList[0]) - # for i in movementList: - # self.map.getEntityOnCoord() # Start game loop - self.mainLoop()