Better debug output

This commit is contained in:
Marcin Kostrzewski 2020-05-15 08:52:06 +02:00
parent 569128763b
commit 4fff56bd7d

View File

@ -129,7 +129,7 @@ def aStar(movable: Entity, target, map):
:return: Array of moves :return: Array of moves
""" """
testCount = 0 testCount = 0
print("Couldn't find path to x:", target.x, " y:", target.y, end='...\n')
fringe = PriorityQueue() fringe = PriorityQueue()
explored = [] explored = []
@ -141,13 +141,13 @@ def aStar(movable: Entity, target, map):
while True: while True:
if fringe.empty(): if fringe.empty():
# target is unreachable # target is unreachable
print("PATH NOT FOUND") print("Couldn't find path to x:", target.x, " y:", target.y, end='.\n')
return None return None
elem: AStarNode = fringe.get()[2] elem: AStarNode = fringe.get()[2]
if goalTest(elem.state, target): if goalTest(elem.state, target):
print("PATH FOUND") print("Found path to x:", target.x, " y:", target.y, end='.\n')
movesList = [] movesList = []
if isinstance(target, Entity) or target in map.collidables: if isinstance(target, Entity) or target in map.collidables:
@ -160,21 +160,6 @@ def aStar(movable: Entity, target, map):
movesList.reverse() movesList.reverse()
return movesList return movesList
# debug
# print("DEBUG")
print("ACTUAL STATE: {}".format(elem.state))
print("HOW TO GET HERE:")
temp = elem
while temp.action is not None:
print(temp.action)
temp = temp.parent
#
# print("POSSIBLE MOVEMENTS FROM HERE:")
# for el in self.successor(elem.state):
# print(el)
#
# print("*" * 20)
explored.append(elem) explored.append(elem)
for (movement, newState) in successor(movable, elem.state, map, target): for (movement, newState) in successor(movable, elem.state, map, target):