method that return travel as correct list work

This commit is contained in:
Mateusz 2020-05-27 00:23:56 +02:00
parent b63be724f5
commit 80c72f1ba0
2 changed files with 10 additions and 5 deletions

View File

@ -33,6 +33,12 @@ class GeneticAlgorithm:
i += 1 i += 1
if self.stopCondition(i): if self.stopCondition(i):
return theBestMatch return str(theBestMatch)
def listOfTravel(self):
strTravel = self.run()
import ast
return ast.literal_eval(strTravel)

View File

@ -421,13 +421,12 @@ class Game:
mutationProbability = float(0.1) mutationProbability = float(0.1)
ga = GeneticAlgorithm(firstGeneration, mutationProbability) ga = GeneticAlgorithm(firstGeneration, mutationProbability)
movementList = ga.run() movementList = ga.listOfTravel()
print(movementList) print(movementList)
print(type(movementList))
print(movementList[0])
# for i in movementList:
# self.map.getEntityOnCoord()
# Start game loop # Start game loop
self.mainLoop() self.mainLoop()