From bd7a7881b290f52797d873d04ecb836da1cce4a2 Mon Sep 17 00:00:00 2001 From: Maciej Sobkowiak Date: Sun, 9 Jun 2019 13:37:29 +0200 Subject: [PATCH] improve move of the truck --- UI/window.py | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/UI/window.py b/UI/window.py index 5a65b58..0a1438f 100644 --- a/UI/window.py +++ b/UI/window.py @@ -72,20 +72,9 @@ class Window(): #draw starting map self.grid.draw_map(self.screen) - for ind, x in enumerate(to_collect): - #copy table - if ind == 0: - array = [[self.grid.table[col][row] for row in range(cols)] for col in range(rows)] - obs = [3,8,6,7] - path = a_path(array,(start[0],start[1]),(x[0],x[1]),obs) - print("Path:",path) - else: - array = [[self.grid.table[col][row] for row in range(cols)] for col in range(rows)] - obs = [3,6,7,8] - path = a_path(array,(to_collect[ind-1][0],to_collect[ind-1][1]),(x[0],x[1]),obs) - print("Path:",path) - - #draw movement of garbage truck + + #move of the truck + def move_truck(path): for index, t in enumerate(path): x,y =t if index != 0: @@ -95,4 +84,29 @@ class Window(): self.grid.draw_node(self.screen, x, y) pg.time.delay(500) + + #visit all points from from to_collect + for ind, x in enumerate(to_collect): + #copy table + obs = [3,8,6,7] + if ind == 0: + array = [[self.grid.table[col][row] for row in range(cols)] for col in range(rows)] + path = a_path(array,(start[0],start[1]),(x[0],x[1]),obs) + print("Path:",path) + else: + array = [[self.grid.table[col][row] for row in range(cols)] for col in range(rows)] + path = a_path(array,(to_collect[ind-1][0],to_collect[ind-1][1]),(x[0],x[1]),obs) + print("Path:",path) + + + #draw movement of garbage truck + move_truck(path) + + + #last move + array = [[self.grid.table[col][row] for row in range(cols)] for col in range(rows)] + path = a_path(array,(to_collect[len(to_collect)-1][0],to_collect[len(to_collect)-1][1]),(end[0],end[1]),obs) + print("Path:",path) + move_truck(path) + pg.quit() # pylint: disable=no-member