diff --git a/__pycache__/bfs.cpython-39.pyc b/__pycache__/bfs.cpython-39.pyc index b61c917..1ae82be 100644 Binary files a/__pycache__/bfs.cpython-39.pyc and b/__pycache__/bfs.cpython-39.pyc differ diff --git a/bfs.py b/bfs.py index 3074435..18f77d4 100644 --- a/bfs.py +++ b/bfs.py @@ -9,6 +9,11 @@ class Node: self.parent = parent self.action = action + def __eq__(self, other): + if isinstance(other, Node): + return self.pos[0] == other.pos[0] and self.pos[1] == other.pos[1] and self.direction == other.direction + return False + def successor(pos, direction, houses): neighbours = [] @@ -38,13 +43,12 @@ def bfs(pos, direction, end_pos, houses): while queue: curr_node = queue.pop(0) - print(curr_node.pos, curr_node.direction) + if not is_house(curr_node.pos, houses) and curr_node.pos == end_pos: while curr_node.parent: print(curr_node.pos, end_pos) actions.append(curr_node.action) curr_node = curr_node.parent - actions.append(curr_node.action) return actions visited.append(curr_node) diff --git a/main.py b/main.py index aa67b20..33908bc 100644 --- a/main.py +++ b/main.py @@ -83,9 +83,9 @@ def game_loop(): print('##################################################') while actions: action = actions.pop() - print(action) pygame.event.post(pygame.event.Event( pygame.KEYDOWN, {'key': action})) + game_keys(truck, trash, houses, True) update_images(gameDisplay, truck, trash, houses) else: