From 2dac7c64a9e7626e0d42aadcb2c6f925d67fd8d5 Mon Sep 17 00:00:00 2001 From: jakzar Date: Sat, 13 Apr 2024 00:13:51 +0200 Subject: [PATCH 01/12] -minor changes to move action (added do_move_if_valid) --- Tractor.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Tractor.py b/Tractor.py index b4f9598..ab4707b 100644 --- a/Tractor.py +++ b/Tractor.py @@ -154,6 +154,9 @@ class Tractor: self.current_tractor_image = self.tractor_images[self.direction] # sprawdzenie czy następny slot jest dobry + self.do_move_if_valid(pole,next_slot_coordinates) + + def do_move_if_valid(self,pole, next_slot_coordinates): if next_slot_coordinates and pole.is_valid_move(next_slot_coordinates): next_slot = pole.get_slot_from_cord(next_slot_coordinates) self.slot.redraw_image() @@ -168,6 +171,9 @@ class Tractor: # wykonanie ruchu do przodu z uwzględnieniem aktualnej orientacji self.move_forward(pole) + def snake_move(self,pole): + pass + #to tak zrobiłam już na później, może się przyda def change_osprzet(self, new_osprzet): -- 2.20.1 From 911876e59abada9207d7b97c458ceaa4a4049713 Mon Sep 17 00:00:00 2001 From: jakzar Date: Sat, 13 Apr 2024 01:39:39 +0200 Subject: [PATCH 02/12] -added initial_move to get all slot's hydrate stats by visiting all slots -added way to get hydrate stats for single slot -added console to print things there instead of terminal --- App.py | 17 +++++++++++++---- Roslina.py | 6 ++++++ Slot.py | 9 ++++++++- Stan.py | 3 +++ Tractor.py | 32 ++++++++++++++++++++++++++++---- Ui.py | 19 +++++++++++++++++-- displayControler.py | 16 +++++++++++++--- 7 files changed, 88 insertions(+), 14 deletions(-) diff --git a/App.py b/App.py index 8029d49..76665ca 100644 --- a/App.py +++ b/App.py @@ -6,19 +6,21 @@ import time import displayControler as dCon import Image import Osprzet +import Ui pygame.init() screen = pygame.display.set_mode((dCon.getScreenWidth(), dCon.getScreenHeihgt())) - +FPS=5 +clock=pygame.time.Clock() image_loader=Image.Image() image_loader.load_images() pole=Pole.Pole(screen,image_loader) pole.draw_grid() #musi byc tutaj wywołane ponieważ inicjalizuje sloty do slownika - +ui=Ui.Ui(screen) #Tractor creation traktor_slot = pole.get_slot_from_cord((0, 0)) -traktor = Tractor.Tractor(traktor_slot, screen, Osprzet.plug) +traktor = Tractor.Tractor(traktor_slot, screen, Osprzet.plug,clock) def init_demo(): #Demo purpose @@ -27,8 +29,14 @@ def init_demo(): #Demo purpose time.sleep(2) pole.randomize_colors() traktor.draw_tractor() + start_flag=True while True: - time.sleep(0.5) + clock.tick(FPS) + if(start_flag): + ui.render_text_to_console(string_to_print="Przejazd inicjalizujacy- traktor sprawdza poziom nawodnienia") + traktor.initial_move(pole) + traktor.reset_pos(pole) + start_flag=False demo_move() old_info=get_info(old_info) for event in pygame.event.get(): @@ -42,6 +50,7 @@ def init(demo): #TODO: Implement + def demo_move(): current_slot = traktor.slot if current_slot: diff --git a/Roslina.py b/Roslina.py index 48f3479..c5a7897 100644 --- a/Roslina.py +++ b/Roslina.py @@ -78,5 +78,11 @@ class Roslina: self.stan.checkStan() return + def return_stan(self): + return self.stan + + def get_hydrate_stats(self): + return self.stan.return_hydrate() + def report_status(self): return f"Nazwa rosliny: {self.nazwa} "+self.stan.report_all() \ No newline at end of file diff --git a/Slot.py b/Slot.py index 4ca10fa..b50f872 100644 --- a/Slot.py +++ b/Slot.py @@ -42,6 +42,13 @@ class Slot: def random_plant(self): #Probably will not be used later only for demo purpouse return self.image_loader.return_random_plant() + + def return_plant(self): + return self.plant + + def get_hydrate_stats(self): + return self.plant.get_hydrate_stats() def print_status(self): - return f"wspolrzedne: (X:{self.x_axis} Y:{self.y_axis}) "+self.plant.report_status() \ No newline at end of file + return f"wspolrzedne: (X:{self.x_axis} Y:{self.y_axis}) "+self.plant.report_status() + \ No newline at end of file diff --git a/Stan.py b/Stan.py index 5789e25..6b9686d 100644 --- a/Stan.py +++ b/Stan.py @@ -44,5 +44,8 @@ class Stan: self.akcja = None return + def return_hydrate(self): + return self.nawodnienie + def report_all(self): return f"Nawodnienie: {self.nawodnienie} Zyznosc: {self.zyznosc} Wzrost: {self.wzrost} Choroba: {self.choroba}" \ No newline at end of file diff --git a/Tractor.py b/Tractor.py index ab4707b..14186fd 100644 --- a/Tractor.py +++ b/Tractor.py @@ -92,7 +92,7 @@ class Tractor: DIRECTION_SOUTH = 'S' DIRECTION_WEST = 'W' DIRECTION_EAST = 'E' - def __init__(self,slot,screen, osprzet): + def __init__(self,slot,screen, osprzet,clock): self.tractor_images = { Tractor.DIRECTION_NORTH: pygame.transform.scale(pygame.image.load('images/traktorN.png'), (dCon.CUBE_SIZE, dCon.CUBE_SIZE)), @@ -108,6 +108,8 @@ class Tractor: self.screen=screen self.slot=slot self.osprzet = osprzet + self.clock=clock + self.slot_hydrate_dict={} def draw_tractor(self): @@ -162,18 +164,40 @@ class Tractor: self.slot.redraw_image() self.slot = next_slot self.draw_tractor() + return True + else: + return False def random_move(self, pole): + self.clock.tick(2) # losowanie skrętu turn_direction = random.choice([self.turn_left, self.turn_right]) turn_direction() - time.sleep(0.5) + self.clock.tick(5) # wykonanie ruchu do przodu z uwzględnieniem aktualnej orientacji self.move_forward(pole) - def snake_move(self,pole): - pass + def reset_pos(self,pole): + self.do_move_if_valid(pole,(0,0)) + def initial_move(self,pole): + for y in range (0,12): + if(y%2==0): + for x in range(0,20): + self.snake_move(pole,x,y) + else: + for x in range(20,0,-1): + self.snake_move(pole,x,y) + + + def snake_move(self,pole,x,y): + next_slot_coordinates=(x,y) + if(self.do_move_if_valid(pole,next_slot_coordinates)): + self.slot_hydrate_dict[(x,y)]= pole.get_slot_from_cord((x,y)).get_hydrate_stats() #Budowanie slownika slotow z poziomem nawodnienia dla traktorka + self.clock.tick(10) + for event in pygame.event.get(): + if event.type == pygame.QUIT: + quit() #to tak zrobiłam już na później, może się przyda def change_osprzet(self, new_osprzet): diff --git a/Ui.py b/Ui.py index 61ffc5c..3f3ccbf 100644 --- a/Ui.py +++ b/Ui.py @@ -7,10 +7,25 @@ class Ui: def __init__(self,screen): self.screen=screen self.font='freesansbold.ttf' #Feel free to change it :D - self.font_size=int(32) + self.font_size=int(16) def render_text(self,string_to_print): font=pygame.font.Font(self.font,self.font_size) text=font.render(string_to_print,True,Colors.BLACK,Colors.WHITE) textRect=text.get_rect() textRect.center=(dCon.getScreenWidth() // 2,dCon.getScreenHeihgt() // 2) - self.screen.blit(text,textRect) \ No newline at end of file + self.screen.blit(text,textRect) + + def render_text_to_console(self,string_to_print): + font=pygame.font.Font(self.font,self.font_size) + self.break_string_to_console(string_to_print) + line=10 + for string in self.to_print: + text=font.render(string,True,Colors.BLACK,Colors.WHITE) + textRect=text.get_rect() + textRect.center=(dCon.getGameWidth()+350/2,line) + textRect.scale_by(x=350,y=100) + self.screen.blit(text,textRect) + line=line+10 + + def break_string_to_console(self,string_to_print): + self.to_print=string_to_print.split(" ") diff --git a/displayControler.py b/displayControler.py index ea90442..9cdf461 100644 --- a/displayControler.py +++ b/displayControler.py @@ -10,8 +10,18 @@ def isValidMove(x, y): return False return True -def getScreenWidth(): - return NUM_X * CUBE_SIZE def getScreenHeihgt(): - return NUM_Y * CUBE_SIZE \ No newline at end of file + return NUM_Y * CUBE_SIZE + +def getGameWidth(): + return NUM_X * CUBE_SIZE + +def getScreenWidth(): + return getGameWidth()+350 + +def getConsoleWidth(): + return 350 + +def getConsoleWidthCenter(): + return getScreenWidth()+getConsoleWidth()/2 \ No newline at end of file -- 2.20.1 From 7ac10932313f14d42d2b9dd44c0f31a6ed93bb91 Mon Sep 17 00:00:00 2001 From: jakzar Date: Sat, 13 Apr 2024 01:51:52 +0200 Subject: [PATCH 03/12] -fix in gap between lines -added option to disable console --- App.py | 3 ++- Ui.py | 4 ++-- displayControler.py | 18 +++++++++++++----- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/App.py b/App.py index 76665ca..d3c0a73 100644 --- a/App.py +++ b/App.py @@ -10,7 +10,8 @@ import Ui pygame.init() -screen = pygame.display.set_mode((dCon.getScreenWidth(), dCon.getScreenHeihgt())) +show_console=True +screen = pygame.display.set_mode((dCon.getScreenWidth(show_console), dCon.getScreenHeihgt())) FPS=5 clock=pygame.time.Clock() image_loader=Image.Image() diff --git a/Ui.py b/Ui.py index 3f3ccbf..c9755cd 100644 --- a/Ui.py +++ b/Ui.py @@ -12,7 +12,7 @@ class Ui: font=pygame.font.Font(self.font,self.font_size) text=font.render(string_to_print,True,Colors.BLACK,Colors.WHITE) textRect=text.get_rect() - textRect.center=(dCon.getScreenWidth() // 2,dCon.getScreenHeihgt() // 2) + textRect.center=(dCon.getGameWidth() // 2,dCon.getScreenHeihgt() // 2) self.screen.blit(text,textRect) def render_text_to_console(self,string_to_print): @@ -25,7 +25,7 @@ class Ui: textRect.center=(dCon.getGameWidth()+350/2,line) textRect.scale_by(x=350,y=100) self.screen.blit(text,textRect) - line=line+10 + line=line+18 def break_string_to_console(self,string_to_print): self.to_print=string_to_print.split(" ") diff --git a/displayControler.py b/displayControler.py index 9cdf461..492395a 100644 --- a/displayControler.py +++ b/displayControler.py @@ -11,14 +11,22 @@ def isValidMove(x, y): return True -def getScreenHeihgt(): - return NUM_Y * CUBE_SIZE - def getGameWidth(): return NUM_X * CUBE_SIZE -def getScreenWidth(): - return getGameWidth()+350 + + + +def getScreenHeihgt(): + return NUM_Y * CUBE_SIZE + + +def getScreenWidth(show_console): + screen_width=getGameWidth() + if(show_console): + print("true") + screen_width=screen_width+350 + return screen_width def getConsoleWidth(): return 350 -- 2.20.1 From 9ca821bab87006e541cc6754e1645933c02a8c5d Mon Sep 17 00:00:00 2001 From: jakzar Date: Sat, 13 Apr 2024 02:09:49 +0200 Subject: [PATCH 04/12] -fixed a bug where mouse on the console would sometimes cause a crash --- Pole.py | 7 +++++-- displayControler.py | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Pole.py b/Pole.py index 017848e..f2c6f4d 100644 --- a/Pole.py +++ b/Pole.py @@ -55,5 +55,8 @@ class Pole: def check_collision(self,mouse_x,mouse_y): mouse_x=math.floor(mouse_x/dCon.CUBE_SIZE) mouse_y=math.floor(mouse_y/dCon.CUBE_SIZE) - collided=self.get_slot_from_cord((mouse_x,mouse_y)) - return collided.print_status() \ No newline at end of file + if(mouse_x<20): + if(mouse_y<12): + collided=self.get_slot_from_cord((mouse_x,mouse_y)) + return collided.print_status() + return "" \ No newline at end of file diff --git a/displayControler.py b/displayControler.py index 492395a..f09da3f 100644 --- a/displayControler.py +++ b/displayControler.py @@ -24,7 +24,6 @@ def getScreenHeihgt(): def getScreenWidth(show_console): screen_width=getGameWidth() if(show_console): - print("true") screen_width=screen_width+350 return screen_width -- 2.20.1 From eb5556e5149a450887e23f708a9eab22cca00902 Mon Sep 17 00:00:00 2001 From: tafit0902 Date: Sat, 13 Apr 2024 23:49:04 +0200 Subject: [PATCH 05/12] poprawki --- Pole.py | 4 ++-- Tractor.py | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Pole.py b/Pole.py index f2c6f4d..983dbf9 100644 --- a/Pole.py +++ b/Pole.py @@ -55,8 +55,8 @@ class Pole: def check_collision(self,mouse_x,mouse_y): mouse_x=math.floor(mouse_x/dCon.CUBE_SIZE) mouse_y=math.floor(mouse_y/dCon.CUBE_SIZE) - if(mouse_x<20): - if(mouse_y<12): + if(mouse_x Date: Sat, 13 Apr 2024 23:55:58 +0200 Subject: [PATCH 06/12] traktor porusza sie po scieszce bfs i nawadnia na sztywno pole --- App.py | 9 +++++++-- Slot.py | 2 ++ Tractor.py | 19 ++++++++++++++++++- displayControler.py | 4 ++-- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/App.py b/App.py index d3c0a73..4a92366 100644 --- a/App.py +++ b/App.py @@ -21,7 +21,7 @@ pole.draw_grid() #musi byc tutaj wywołane ponieważ inicjalizuje sloty do slown ui=Ui.Ui(screen) #Tractor creation traktor_slot = pole.get_slot_from_cord((0, 0)) -traktor = Tractor.Tractor(traktor_slot, screen, Osprzet.plug,clock) +traktor = Tractor.Tractor(traktor_slot, screen, Osprzet.opryskiwacz,clock) def init_demo(): #Demo purpose @@ -37,8 +37,13 @@ def init_demo(): #Demo purpose ui.render_text_to_console(string_to_print="Przejazd inicjalizujacy- traktor sprawdza poziom nawodnienia") traktor.initial_move(pole) traktor.reset_pos(pole) + bfsRoot = Tractor.BFS({"x": 0, "y": 0, "direction": "E", "hydradeIndex": traktor.slot_hydrate_dict}) + bfsRoot.reverse() + print(bfsRoot) + # ui.render_text(string_to_print="traktor porusza się ścieżką bfs") + traktor.move_by_root(bfsRoot, pole, traktor.irrigateSlot) start_flag=False - demo_move() + # demo_move() old_info=get_info(old_info) for event in pygame.event.get(): if event.type == pygame.QUIT: diff --git a/Slot.py b/Slot.py index b50f872..262ee12 100644 --- a/Slot.py +++ b/Slot.py @@ -51,4 +51,6 @@ class Slot: def print_status(self): return f"wspolrzedne: (X:{self.x_axis} Y:{self.y_axis}) "+self.plant.report_status() + def irrigatePlant(self): + self.plant.stan.nawodnienie = 100 \ No newline at end of file diff --git a/Tractor.py b/Tractor.py index 74afc34..0e8aa5a 100644 --- a/Tractor.py +++ b/Tractor.py @@ -72,7 +72,12 @@ def BFS(istate): elem = fringe.pop(0) if goalTest(elem.state["hydradeIndex"]): - return elem #TODO ciąg akcji zbudowany z wykorzystaniem pól parent i action + x = elem + tab = [] + while x.parent != None: + tab.append(x.action) + x = x.parent + return tab explored.append(elem) @@ -202,6 +207,16 @@ class Tractor: for event in pygame.event.get(): if event.type == pygame.QUIT: quit() + def move_by_root(self, root, pole, action): + for move in root: + if move == 'forward': + self.move_forward(pole) + if move == 'right': + self.turn_right() + if move == 'left': + self.turn_left() + action() + self.clock.tick(3) #to tak zrobiłam już na później, może się przyda def change_osprzet(self, new_osprzet): @@ -217,4 +232,6 @@ class Tractor: print("- Typ:", akcja.typ) else: print("Brak akcji przypisanych do tego sprzętu.") + def irrigateSlot(self): + self.slot.irrigatePlant() diff --git a/displayControler.py b/displayControler.py index f09da3f..cad2f16 100644 --- a/displayControler.py +++ b/displayControler.py @@ -1,6 +1,6 @@ CUBE_SIZE = 64 -NUM_X = 20 -NUM_Y = 12 +NUM_X = 5 +NUM_Y = 3 #returns true if tractor can move to specified slot def isValidMove(x, y): -- 2.20.1 From fbe6a7e386e36f8926d5c473e06c63c848ad3886 Mon Sep 17 00:00:00 2001 From: tafit0902 Date: Sun, 14 Apr 2024 00:13:27 +0200 Subject: [PATCH 07/12] poprawa obrotu traktora --- App.py | 2 +- Tractor.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/App.py b/App.py index 4a92366..9ae7626 100644 --- a/App.py +++ b/App.py @@ -41,7 +41,7 @@ def init_demo(): #Demo purpose bfsRoot.reverse() print(bfsRoot) # ui.render_text(string_to_print="traktor porusza się ścieżką bfs") - traktor.move_by_root(bfsRoot, pole, traktor.irrigateSlot) + traktor.move_by_root(bfsRoot, pole, [traktor.irrigateSlot]) start_flag=False # demo_move() old_info=get_info(old_info) diff --git a/Tractor.py b/Tractor.py index 0e8aa5a..8cbee1f 100644 --- a/Tractor.py +++ b/Tractor.py @@ -207,15 +207,18 @@ class Tractor: for event in pygame.event.get(): if event.type == pygame.QUIT: quit() - def move_by_root(self, root, pole, action): + def move_by_root(self, root, pole, actions = None): for move in root: + self.slot.redraw_image() if move == 'forward': self.move_forward(pole) if move == 'right': self.turn_right() if move == 'left': self.turn_left() - action() + for a in actions: + a() + self.clock.tick(3) #to tak zrobiłam już na później, może się przyda -- 2.20.1 From 2c03c4857cb2178b5b12dd609e3afa5d1ccd3b3d Mon Sep 17 00:00:00 2001 From: tafit0902 Date: Sun, 14 Apr 2024 00:41:18 +0200 Subject: [PATCH 08/12] poprawki --- App.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/App.py b/App.py index 9ae7626..be9f2d5 100644 --- a/App.py +++ b/App.py @@ -39,8 +39,7 @@ def init_demo(): #Demo purpose traktor.reset_pos(pole) bfsRoot = Tractor.BFS({"x": 0, "y": 0, "direction": "E", "hydradeIndex": traktor.slot_hydrate_dict}) bfsRoot.reverse() - print(bfsRoot) - # ui.render_text(string_to_print="traktor porusza się ścieżką bfs") + # ui.render_text_to_console(string_to_print="traktor porusza się ścieżką bfs") traktor.move_by_root(bfsRoot, pole, [traktor.irrigateSlot]) start_flag=False # demo_move() -- 2.20.1 From 63229b2c6094a9e4134c5aedf5adbfbf75379e13 Mon Sep 17 00:00:00 2001 From: Mateusz Czajka Date: Sun, 14 Apr 2024 21:39:04 +0200 Subject: [PATCH 09/12] Made BFS1 and BFS3 algorithm in BFS.py file. --- App.py | 17 ++- BFS.py | 254 ++++++++++++++++++++++++++++++++++++++++++++ Tractor.py | 95 ++--------------- displayControler.py | 2 +- 4 files changed, 276 insertions(+), 92 deletions(-) create mode 100644 BFS.py diff --git a/App.py b/App.py index be9f2d5..6a994a7 100644 --- a/App.py +++ b/App.py @@ -7,6 +7,7 @@ import displayControler as dCon import Image import Osprzet import Ui +import BFS pygame.init() @@ -37,10 +38,20 @@ def init_demo(): #Demo purpose ui.render_text_to_console(string_to_print="Przejazd inicjalizujacy- traktor sprawdza poziom nawodnienia") traktor.initial_move(pole) traktor.reset_pos(pole) - bfsRoot = Tractor.BFS({"x": 0, "y": 0, "direction": "E", "hydradeIndex": traktor.slot_hydrate_dict}) - bfsRoot.reverse() + + bfsRoot1 = BFS.BFS1({"x": 0, "y": 0, "direction": "E", "hydradeIndex": traktor.slot_hydrate_dict}) #displayControler: NUM_X: 6, NUM_Y: 3 (klasyczne) + #bfsRoot2 = [[{'x': 2, 'y': 2, 'direction': 'N', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 1, (1, 2): 1, (2, 2): 1, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 1, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 2, 'y': 2, 'direction': 'E', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 1, (1, 2): 1, (2, 2): 1, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 1, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'left'], [{'x': 1, 'y': 2, 'direction': 'E', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 1, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 1, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 0, 'y': 2, 'direction': 'E', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 1, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 1, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 0, 'y': 2, 'direction': 'N', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 1, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 1, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'right'], [{'x': 0, 'y': 3, 'direction': 'N', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 1, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 0, 'y': 3, 'direction': 'W', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 1, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'right'], [{'x': 1, 'y': 3, 'direction': 'W', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 1, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 2, 'y': 3, 'direction': 'W', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 3, 'y': 3, 'direction': 'W', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 4, 'y': 3, 'direction': 'W', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 4, 'y': 3, 'direction': 'S', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'right'], [{'x': 4, 'y': 2, 'direction': 'S', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 0, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 4, 'y': 1, 'direction': 'S', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 0, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 0, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 4, 'y': 0, 'direction': 'S', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 0, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 0, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 0, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 4, 'y': 0, 'direction': 'E', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 0, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 0, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 0, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'right'], [{'x': 3, 'y': 0, 'direction': 'E', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 0, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 0, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 0, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 0, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 2, 'y': 0, 'direction': 'E', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 0, (4, 0): 0, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 0, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 0, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 0, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 1, 'y': 0, 'direction': 'E', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 0, (3, 0): 0, (4, 0): 0, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 0, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 0, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 0, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 0, 'y': 0, 'direction': 'E', 'hydradeIndex': {(0, 0): -1, (1, 0): 0, (2, 0): 0, (3, 0): 0, (4, 0): 0, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 0, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 0, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 0, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward']] #displayControler: NUM_X: 10, NUM_Y: 5 (klasyczne - duże) + #bfsRoot3 = BFS.BFS2({'x': 0, 'y': 0, 'direction': "E"}) #displayControler: NUM_X: 20, NUM_Y: 12 (skarb) + + bfsRoot1.reverse() + #bfsRoot2.reverse() + #bfsRoot3.reverse() # ui.render_text_to_console(string_to_print="traktor porusza się ścieżką bfs") - traktor.move_by_root(bfsRoot, pole, [traktor.irrigateSlot]) + + traktor.move_by_root(bfsRoot1, pole, [traktor.irrigateSlot]) + #traktor.move_by_root(bfsRoot2, pole, [traktor.irrigateSlot]) + #traktor.move_by_root(bfsRoot3, pole, [traktor.irrigateSlot]) + start_flag=False # demo_move() old_info=get_info(old_info) diff --git a/BFS.py b/BFS.py new file mode 100644 index 0000000..23cb7f3 --- /dev/null +++ b/BFS.py @@ -0,0 +1,254 @@ +import random +import Node +from displayControler import NUM_X, NUM_Y + + +def goalTest1(hIndex): + for i in list(hIndex.values()): + if i == 0: + return False + return True + + +def succ1(state): + resp = [] + hIndex = state["hydradeIndex"].copy() + if state["direction"] == "N": + if state["y"] > 0: + if hIndex[state["x"], state["y"]-1] == 0: + hIndex[state["x"], state["y"] - 1] = 1 + resp.append(["forward", {'x': state["x"], 'y': state["y"]-1, 'direction': state["direction"], 'hydradeIndex': hIndex}]) + resp.append(["right", {'x': state["x"], 'y': state["y"], 'direction': "E", 'hydradeIndex': state["hydradeIndex"].copy()}]) + resp.append(["left", {'x': state["x"], 'y': state["y"], 'direction': "W", 'hydradeIndex': state["hydradeIndex"].copy()}]) + elif state["direction"] == "S": + if state["y"] < NUM_Y-1: + if hIndex[state["x"], state["y"]+1] == 0: + hIndex[state["x"], state["y"] + 1] = 1 + resp.append(["forward", {'x': state["x"], 'y': state["y"]+1, 'direction': state["direction"], 'hydradeIndex': hIndex}]) + resp.append(["right", {'x': state["x"], 'y': state["y"], 'direction': "W", 'hydradeIndex': state["hydradeIndex"].copy()}]) + resp.append(["left", {'x': state["x"], 'y': state["y"], 'direction': "E", 'hydradeIndex': state["hydradeIndex"].copy()}]) + elif state["direction"] == "E": + if state["x"] < NUM_X-1: + if hIndex[state["x"]+1, state["y"]] == 0: + hIndex[state["x"] + 1, state["y"]] = 1 + resp.append(["forward", {'x': state["x"]+1, 'y': state["y"], 'direction': state["direction"], 'hydradeIndex': hIndex}]) + resp.append(["right", {'x': state["x"], 'y': state["y"], 'direction': "S", 'hydradeIndex': state["hydradeIndex"].copy()}]) + resp.append(["left", {'x': state["x"], 'y': state["y"], 'direction': "N", 'hydradeIndex': state["hydradeIndex"].copy()}]) + else: #state["zwrot"] == "W" + if state["x"] > 0: + if hIndex[state["x"]-1, state["y"]] == 0: + hIndex[state["x"] - 1, state["y"]] = 1 + resp.append(["forward", {'x': state["x"]-1, 'y': state["y"], 'direction': state["direction"], 'hydradeIndex': hIndex}]) + resp.append(["right", {'x': state["x"], 'y': state["y"], 'direction': "N", 'hydradeIndex': state["hydradeIndex"].copy()}]) + resp.append(["left", {'x': state["x"], 'y': state["y"], 'direction': "S", 'hydradeIndex': state["hydradeIndex"].copy()}]) + + return resp + + +def check1(tab, state): + for i in tab: + if i.state == state: + return False + return True + + +def BFS1(istate): + + + fringe = [] + explored = [] + + x = Node.Node(istate) + fringe.append(x) + + while True: + + + if fringe == []: + return False + + elem = fringe.pop(0) + + if goalTest1(elem.state["hydradeIndex"]): + x = elem + tab = [] + while x.parent != None: + tab.append([x.parent, x.action]) + x = x.parent + return tab + explored.append(elem) + + for resp in succ1(elem.state): + if check1(fringe, resp[1]) and check1(explored, resp[1]): + x = Node.Node(resp[1]) + x.parent = elem + x.action = resp[0] + fringe.append(x) + + + + +def goalTest2(state, goalTreassure): + if state["x"] == goalTreassure[0] and state["y"] == goalTreassure[1]: + return True + return False + + +def succ2(state): + resp = [] + if state["direction"] == "N": + if state["y"] > 0: + resp.append(["forward", {'x': state["x"], 'y': state["y"]-1, 'direction': state["direction"]}]) + resp.append(["right", {'x': state["x"], 'y': state["y"], 'direction': "E"}]) + resp.append(["left", {'x': state["x"], 'y': state["y"], 'direction': "W"}]) + elif state["direction"] == "S": + if state["y"] < NUM_Y: + resp.append(["forward", {'x': state["x"], 'y': state["y"]+1, 'direction': state["direction"]}]) + resp.append(["right", {'x': state["x"], 'y': state["y"], 'direction': "W"}]) + resp.append(["left", {'x': state["x"], 'y': state["y"], 'direction': "E"}]) + elif state["direction"] == "E": + if state["x"] < NUM_X: + resp.append(["forward", {'x': state["x"]+1, 'y': state["y"], 'direction': state["direction"]}]) + resp.append(["right", {'x': state["x"], 'y': state["y"], 'direction': "S"}]) + resp.append(["left", {'x': state["x"], 'y': state["y"], 'direction': "N"}]) + else: #state["zwrot"] == "W" + if state["x"] > 0: + resp.append(["forward", {'x': state["x"]-1, 'y': state["y"], 'direction': state["direction"]}]) + resp.append(["right", {'x': state["x"], 'y': state["y"], 'direction': "N"}]) + resp.append(["left", {'x': state["x"], 'y': state["y"], 'direction': "S"}]) + + return resp + + +def check2(tab, state): + for i in tab: + if i.state == state: + return False + return True + + +def BFS2(istate): + goalTreassuere = (random.randint(0,NUM_X-1), random.randint(0,NUM_Y-1)) + print(goalTreassuere) + fringe = [] + explored = [] + + x = Node.Node(istate) + fringe.append(x) + + while True: + + if fringe == []: + return False + + elem = fringe.pop(0) + + if goalTest2(elem.state, goalTreassuere): + x = elem + tab = [] + while x.parent != None: + tab.append([x.parent, x.action]) + x = x.parent + return tab + + explored.append(elem) + + for resp in succ2(elem.state): + if check2(fringe, resp[1]) and check2(explored, resp[1]): + x = Node.Node(resp[1]) + x.parent = elem + x.action = resp[0] + fringe.append(x) + + + + +""" +def goalTest(hIndex): + for i in list(hIndex.values()): + if i == 0: + return False + return True + + +def succ(state): + resp = [] + hIndex = state["hydradeIndex"].copy() + + if state["direction"] == "N": + if state["y"] > 0: + if hIndex[state["x"], state["y"]-1] == 0: + hIndex[state["x"], state["y"] - 1] = 1 + resp.append(["forward", {'x': state["x"], 'y': state["y"]-1, 'direction': state["direction"], 'hydradeIndex': hIndex}]) + resp.append(["right", {'x': state["x"], 'y': state["y"], 'direction': "E", 'hydradeIndex': state["hydradeIndex"].copy()}]) + resp.append(["left", {'x': state["x"], 'y': state["y"], 'direction': "W", 'hydradeIndex': state["hydradeIndex"].copy()}]) + elif state["direction"] == "S": + if state["y"] < dCon.NUM_Y-1: + if hIndex[state["x"], state["y"]+1] == 0: + hIndex[state["x"], state["y"] + 1] = 1 + resp.append(["forward", {'x': state["x"], 'y': state["y"]+1, 'direction': state["direction"], 'hydradeIndex': hIndex}]) + resp.append(["right", {'x': state["x"], 'y': state["y"], 'direction': "W", 'hydradeIndex': state["hydradeIndex"].copy()}]) + resp.append(["left", {'x': state["x"], 'y': state["y"], 'direction': "E", 'hydradeIndex': state["hydradeIndex"].copy()}]) + elif state["direction"] == "E": + if state["x"] < dCon.NUM_X-1: + if hIndex[state["x"]+1, state["y"]] == 0: + hIndex[state["x"] + 1, state["y"]] = 1 + resp.append(["forward", {'x': state["x"]+1, 'y': state["y"], 'direction': state["direction"], 'hydradeIndex': hIndex}]) + resp.append(["right", {'x': state["x"], 'y': state["y"], 'direction': "S", 'hydradeIndex': state["hydradeIndex"].copy()}]) + resp.append(["left", {'x': state["x"], 'y': state["y"], 'direction': "N", 'hydradeIndex': state["hydradeIndex"].copy()}]) + else: #state["direction"] == "W" + if state["x"] > 0: + if hIndex[state["x"]-1, state["y"]] == 0: + hIndex[state["x"] - 1, state["y"]] = 1 + resp.append(["forward", {'x': state["x"]-1, 'y': state["y"], 'direction': state["direction"], 'hydradeIndex': hIndex}]) + resp.append(["right", {'x': state["x"], 'y': state["y"], 'direction': "N", 'hydradeIndex': state["hydradeIndex"].copy()}]) + resp.append(["left", {'x': state["x"], 'y': state["y"], 'direction': "S", 'hydradeIndex': state["hydradeIndex"].copy()}]) + + return resp + + +def check(tab, state): + for i in tab: + if i.state == state: + return False + return True + + +def BFS(istate): + fringe = [] + explored = [] + + x = Node.Node(istate) + fringe.append(x) + + while True: + if fringe == []: + return False + + elem = fringe.pop(0) + + if goalTest(elem.state["hydradeIndex"]): + x = elem + tab = [] + while x.parent != None: + tab.append(x.action) + x = x.parent + return tab + + explored.append(elem) + + for resp in succ(elem.state): + if check(fringe, resp[1]) and check(explored, resp[1]): + x = Node.Node(resp[1]) + x.parent = elem + x.action = resp[0] + fringe.append(x) +""" + + + + + + + + diff --git a/Tractor.py b/Tractor.py index 8cbee1f..74c8645 100644 --- a/Tractor.py +++ b/Tractor.py @@ -8,90 +8,6 @@ import Node -def goalTest(hIndex): - for i in list(hIndex.values()): - if i == 0: - return False - return True - - -def succ(state): - resp = [] - hIndex = state["hydradeIndex"].copy() - - if state["direction"] == "N": - if state["y"] > 0: - if hIndex[state["x"], state["y"]-1] == 0: - hIndex[state["x"], state["y"] - 1] = 1 - resp.append(["forward", {'x': state["x"], 'y': state["y"]-1, 'direction': state["direction"], 'hydradeIndex': hIndex}]) - resp.append(["right", {'x': state["x"], 'y': state["y"], 'direction': "E", 'hydradeIndex': state["hydradeIndex"].copy()}]) - resp.append(["left", {'x': state["x"], 'y': state["y"], 'direction': "W", 'hydradeIndex': state["hydradeIndex"].copy()}]) - elif state["direction"] == "S": - if state["y"] < dCon.NUM_Y-1: - if hIndex[state["x"], state["y"]+1] == 0: - hIndex[state["x"], state["y"] + 1] = 1 - resp.append(["forward", {'x': state["x"], 'y': state["y"]+1, 'direction': state["direction"], 'hydradeIndex': hIndex}]) - resp.append(["right", {'x': state["x"], 'y': state["y"], 'direction': "W", 'hydradeIndex': state["hydradeIndex"].copy()}]) - resp.append(["left", {'x': state["x"], 'y': state["y"], 'direction': "E", 'hydradeIndex': state["hydradeIndex"].copy()}]) - elif state["direction"] == "E": - if state["x"] < dCon.NUM_X-1: - if hIndex[state["x"]+1, state["y"]] == 0: - hIndex[state["x"] + 1, state["y"]] = 1 - resp.append(["forward", {'x': state["x"]+1, 'y': state["y"], 'direction': state["direction"], 'hydradeIndex': hIndex}]) - resp.append(["right", {'x': state["x"], 'y': state["y"], 'direction': "S", 'hydradeIndex': state["hydradeIndex"].copy()}]) - resp.append(["left", {'x': state["x"], 'y': state["y"], 'direction': "N", 'hydradeIndex': state["hydradeIndex"].copy()}]) - else: #state["direction"] == "W" - if state["x"] > 0: - if hIndex[state["x"]-1, state["y"]] == 0: - hIndex[state["x"] - 1, state["y"]] = 1 - resp.append(["forward", {'x': state["x"]-1, 'y': state["y"], 'direction': state["direction"], 'hydradeIndex': hIndex}]) - resp.append(["right", {'x': state["x"], 'y': state["y"], 'direction': "N", 'hydradeIndex': state["hydradeIndex"].copy()}]) - resp.append(["left", {'x': state["x"], 'y': state["y"], 'direction': "S", 'hydradeIndex': state["hydradeIndex"].copy()}]) - - return resp - - -def check(tab, state): - for i in tab: - if i.state == state: - return False - return True - - -def BFS(istate): - fringe = [] - explored = [] - - x = Node.Node(istate) - fringe.append(x) - - while True: - if fringe == []: - return False - - elem = fringe.pop(0) - - if goalTest(elem.state["hydradeIndex"]): - x = elem - tab = [] - while x.parent != None: - tab.append(x.action) - x = x.parent - return tab - - explored.append(elem) - - for resp in succ(elem.state): - if check(fringe, resp[1]) and check(explored, resp[1]): - x = Node.Node(resp[1]) - x.parent = elem - x.action = resp[0] - fringe.append(x) - - - - - class Tractor: DIRECTION_NORTH = 'N' DIRECTION_SOUTH = 'S' @@ -198,7 +114,9 @@ class Tractor: def snake_move(self,pole,x,y): next_slot_coordinates=(x,y) if(self.do_move_if_valid(pole,next_slot_coordinates)): - if pole.get_slot_from_cord((x,y)).get_hydrate_stats() < 60: + if x == 0 and y == 0: + hydrateIndex = -1 + elif pole.get_slot_from_cord((x,y)).get_hydrate_stats() < 60: hydrateIndex = 0 else: hydrateIndex = 1 @@ -207,14 +125,15 @@ class Tractor: for event in pygame.event.get(): if event.type == pygame.QUIT: quit() + def move_by_root(self, root, pole, actions = None): for move in root: self.slot.redraw_image() - if move == 'forward': + if move[1] == 'forward': self.move_forward(pole) - if move == 'right': + if move[1] == 'right': self.turn_right() - if move == 'left': + if move[1] == 'left': self.turn_left() for a in actions: a() diff --git a/displayControler.py b/displayControler.py index cad2f16..f5cb408 100644 --- a/displayControler.py +++ b/displayControler.py @@ -1,5 +1,5 @@ CUBE_SIZE = 64 -NUM_X = 5 +NUM_X = 6 NUM_Y = 3 #returns true if tractor can move to specified slot -- 2.20.1 From d38c4d95934f791849bf0952a1054c96cd772726 Mon Sep 17 00:00:00 2001 From: jakzar Date: Mon, 15 Apr 2024 10:02:09 +0200 Subject: [PATCH 10/12] -Added garage -Fixed bugs that were causing crashes realted to mouse position out of the window --- App.py | 13 ++++++++----- Image.py | 8 +++++++- Pole.py | 7 ++++++- Slot.py | 6 ++++++ Tractor.py | 5 ++++- images/garage.png | Bin 0 -> 11704 bytes 6 files changed, 31 insertions(+), 8 deletions(-) create mode 100644 images/garage.png diff --git a/App.py b/App.py index 6a994a7..2a7bc1e 100644 --- a/App.py +++ b/App.py @@ -74,11 +74,14 @@ def demo_move(): traktor.random_move(pole) def get_info(old_info): - (x,y)=pygame.mouse.get_pos() - new_info=pole.check_collision(x,y) - if(old_info!=new_info): - print(new_info) - return new_info + try: + (x,y)=pygame.mouse.get_pos() + new_info=pole.check_collision(x,y) + if(old_info!=new_info): + print(new_info) + return new_info + except: + pass diff --git a/Image.py b/Image.py index 4bd8136..a924bd0 100644 --- a/Image.py +++ b/Image.py @@ -6,6 +6,7 @@ class Image: def __init__(self): self.plants_image_dict={} self.tractor_image=None + self.garage_image=None def load_images(self): files_plants={0:"borowka", 1:"kukurydza", @@ -19,6 +20,8 @@ class Image: self.plants_image_dict[files_plants[index]]=plant_image tractor_image=pygame.image.load("images/traktor.png") tractor_image=pygame.transform.scale(tractor_image,(dCon.CUBE_SIZE,dCon.CUBE_SIZE)) + garage=pygame.image.load("images/garage.png") + self.garage_image=pygame.transform.scale(garage,(dCon.CUBE_SIZE,dCon.CUBE_SIZE)) def return_random_plant(self): x=random.randint(0,5) keys=list(self.plants_image_dict.keys()) @@ -26,4 +29,7 @@ class Image: return (plant,self.plants_image_dict[plant]) def return_plant(self,plant_name): - return (plant_name,self.plants_image_dict[plant_name]) \ No newline at end of file + return (plant_name,self.plants_image_dict[plant_name]) + + def return_garage(self): + return self.garage_image \ No newline at end of file diff --git a/Pole.py b/Pole.py index 983dbf9..dc7d82e 100644 --- a/Pole.py +++ b/Pole.py @@ -33,13 +33,18 @@ class Pole: slot_dict=self.get_slot_dict() for coordinates in slot_dict: slot_dict[coordinates].draw() + garage=self.slot_dict[(0,0)] + garage.set_garage_image() def randomize_colors(self): pygame.display.update() time.sleep(3) self.ui.render_text("Randomizing Crops") for coordinates in self.slot_dict: - self.slot_dict[coordinates].set_random_plant() + if(coordinates==(0,0)): + continue + else: + self.slot_dict[coordinates].set_random_plant() def change_color_of_slot(self,coordinates,color): #Coordinates must be tuple (x,y) (left top slot has cord (0,0) ), color has to be from defined in Colors.py or custom in RGB value (R,G,B) self.get_slot_from_cord(coordinates).color_change(color) diff --git a/Slot.py b/Slot.py index 262ee12..15511dc 100644 --- a/Slot.py +++ b/Slot.py @@ -15,6 +15,7 @@ class Slot: self.screen=screen self.field=pygame.Rect(self.x_axis*dCon.CUBE_SIZE,self.y_axis*dCon.CUBE_SIZE,dCon.CUBE_SIZE,dCon.CUBE_SIZE) self.image_loader=image_loader + self.garage_image=None def draw(self): pygame.draw.rect(self.screen,Colors.BROWN,self.field,0) #Draw field @@ -39,6 +40,11 @@ class Slot: self.screen.blit(self.plant_image, (self.x_axis * dCon.CUBE_SIZE, self.y_axis * dCon.CUBE_SIZE)) pygame.draw.rect(self.screen, Colors.BLACK, self.field, BORDER_THICKNESS) + def set_garage_image(self): + self.plant_image=self.image_loader.return_garage() + self.screen.blit(self.plant_image, (self.x_axis * dCon.CUBE_SIZE, self.y_axis * dCon.CUBE_SIZE)) + pygame.draw.rect(self.screen, Colors.BLACK, self.field, BORDER_THICKNESS) + def random_plant(self): #Probably will not be used later only for demo purpouse return self.image_loader.return_random_plant() diff --git a/Tractor.py b/Tractor.py index 74c8645..2c0dfe3 100644 --- a/Tractor.py +++ b/Tractor.py @@ -155,5 +155,8 @@ class Tractor: else: print("Brak akcji przypisanych do tego sprzętu.") def irrigateSlot(self): - self.slot.irrigatePlant() + try: + self.slot.irrigatePlant() + except: + pass diff --git a/images/garage.png b/images/garage.png new file mode 100644 index 0000000000000000000000000000000000000000..f9ca1c0e200a573db21fee68709828966450903c GIT binary patch literal 11704 zcmb`NS5y>4;)(zBU3}-_T%2{ji&E)oNNKi_p_UdIOu81RMD5iD5k8Jky0?a;+kQFO?y#u0T%p}V?uPmu^g2rE34oRC&5gLKpR;-}7hzfh15IE9J0LO&SYY6nv zAO11JhQ(sra+Uqt{v2+!j~Z*_QPWBLl(H)c&ib5p?Cx9~&&Bn>l#ElZAxs{B&4dA2 zVvmrRVHX3bF>ToRM_X4d{BYzfFOgi@r=n;)3lL*JcNw-YT!a#q31wVqGEN*JWIK^I3`Q|#P!T)STg`Sh}9F27uNpnHNFaImqR#rKH`SAy1U)~eX{ zIL6d4-QwZuf9Dn4fIvAJQ`P^tO*RJkXDSBTaGiErEZvV(>!G8F@ZZU8f0{{6P2HwA z7s^U4!JvQT!4+C9)+O?`?Q$JX3-S9b z`9Z6ki5yO>iP_Ij&eg^>|Lo@@LfYQkdb#;zBv&7tO$MT-Z)OsRUd|X;T)&cC1Df>kBj*SY=D41bJ z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(?yZ5~oS`LFBfB2Cxb*ha!-V zRRlt3tA0e=(vN-)HSP}~88zd`8qohx;qia7YaDXHmwW^=g^bf)nJ`kdHQ5avBkgi6 HJIwzAPKkH3 literal 0 HcmV?d00001 -- 2.20.1 From e0397b95a7a9880a69748df32aa57d4b2e2a1706 Mon Sep 17 00:00:00 2001 From: jakzar Date: Mon, 15 Apr 2024 10:49:25 +0200 Subject: [PATCH 11/12] -Added support to precalculated BFS2 -Added way to set HydrateValue by HydrateIndex -Minor changes in Tractor.py -Added flags to make handling different BFS implements easier --- App.py | 32 +++++++++++++++++++------------- BFS.py | 8 ++++++++ Slot.py | 8 ++++++++ Tractor.py | 39 +++++++++++++++++++++++++++++++-------- displayControler.py | 4 ++-- 5 files changed, 68 insertions(+), 23 deletions(-) diff --git a/App.py b/App.py index 2a7bc1e..0fe7caa 100644 --- a/App.py +++ b/App.py @@ -21,8 +21,11 @@ pole=Pole.Pole(screen,image_loader) pole.draw_grid() #musi byc tutaj wywołane ponieważ inicjalizuje sloty do slownika ui=Ui.Ui(screen) #Tractor creation +bfs1_flag=False +bfs2_flag=True #Change this lines to show different bfs implementation +bfs3_flag=False traktor_slot = pole.get_slot_from_cord((0, 0)) -traktor = Tractor.Tractor(traktor_slot, screen, Osprzet.opryskiwacz,clock) +traktor = Tractor.Tractor(traktor_slot, screen, Osprzet.opryskiwacz,clock,bfs2_flag) def init_demo(): #Demo purpose @@ -38,20 +41,23 @@ def init_demo(): #Demo purpose ui.render_text_to_console(string_to_print="Przejazd inicjalizujacy- traktor sprawdza poziom nawodnienia") traktor.initial_move(pole) traktor.reset_pos(pole) - - bfsRoot1 = BFS.BFS1({"x": 0, "y": 0, "direction": "E", "hydradeIndex": traktor.slot_hydrate_dict}) #displayControler: NUM_X: 6, NUM_Y: 3 (klasyczne) - #bfsRoot2 = [[{'x': 2, 'y': 2, 'direction': 'N', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 1, (1, 2): 1, (2, 2): 1, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 1, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 2, 'y': 2, 'direction': 'E', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 1, (1, 2): 1, (2, 2): 1, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 1, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'left'], [{'x': 1, 'y': 2, 'direction': 'E', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 1, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 1, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 0, 'y': 2, 'direction': 'E', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 1, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 1, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 0, 'y': 2, 'direction': 'N', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 1, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 1, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'right'], [{'x': 0, 'y': 3, 'direction': 'N', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 1, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 0, 'y': 3, 'direction': 'W', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 1, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'right'], [{'x': 1, 'y': 3, 'direction': 'W', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 1, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 2, 'y': 3, 'direction': 'W', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 3, 'y': 3, 'direction': 'W', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 4, 'y': 3, 'direction': 'W', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 4, 'y': 3, 'direction': 'S', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'right'], [{'x': 4, 'y': 2, 'direction': 'S', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 0, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 4, 'y': 1, 'direction': 'S', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 0, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 0, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 4, 'y': 0, 'direction': 'S', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 0, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 0, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 0, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 4, 'y': 0, 'direction': 'E', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 0, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 0, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 0, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'right'], [{'x': 3, 'y': 0, 'direction': 'E', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 0, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 0, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 0, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 0, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 2, 'y': 0, 'direction': 'E', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 0, (4, 0): 0, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 0, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 0, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 0, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 1, 'y': 0, 'direction': 'E', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 0, (3, 0): 0, (4, 0): 0, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 0, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 0, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 0, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 0, 'y': 0, 'direction': 'E', 'hydradeIndex': {(0, 0): -1, (1, 0): 0, (2, 0): 0, (3, 0): 0, (4, 0): 0, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 0, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 0, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 0, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward']] #displayControler: NUM_X: 10, NUM_Y: 5 (klasyczne - duże) - #bfsRoot3 = BFS.BFS2({'x': 0, 'y': 0, 'direction': "E"}) #displayControler: NUM_X: 20, NUM_Y: 12 (skarb) - - bfsRoot1.reverse() - #bfsRoot2.reverse() - #bfsRoot3.reverse() + if(bfs1_flag): + bfsRoot1 = BFS.BFS1({"x": 0, "y": 0, "direction": "E", "hydradeIndex": traktor.slot_hydrate_dict}) + #displayControler: NUM_X: 6, NUM_Y: 3 (klasyczne) CHANGE THIS BY HAND + bfsRoot1.reverse() + traktor.move_by_root(bfsRoot1, pole, [traktor.irrigateSlot]) + if(bfs2_flag): + bfsRoot2 = [[{'x': 2, 'y': 2, 'direction': 'N', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 1, (1, 2): 1, (2, 2): 1, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 1, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 2, 'y': 2, 'direction': 'E', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 1, (1, 2): 1, (2, 2): 1, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 1, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'left'], [{'x': 1, 'y': 2, 'direction': 'E', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 1, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 1, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 0, 'y': 2, 'direction': 'E', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 1, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 1, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 0, 'y': 2, 'direction': 'N', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 1, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 1, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'right'], [{'x': 0, 'y': 3, 'direction': 'N', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 1, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 0, 'y': 3, 'direction': 'W', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 1, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'right'], [{'x': 1, 'y': 3, 'direction': 'W', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 1, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 2, 'y': 3, 'direction': 'W', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 3, 'y': 3, 'direction': 'W', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 4, 'y': 3, 'direction': 'W', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 4, 'y': 3, 'direction': 'S', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'right'], [{'x': 4, 'y': 2, 'direction': 'S', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 0, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 4, 'y': 1, 'direction': 'S', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 0, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 0, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 4, 'y': 0, 'direction': 'S', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 0, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 0, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 0, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 4, 'y': 0, 'direction': 'E', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 0, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 0, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 0, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'right'], [{'x': 3, 'y': 0, 'direction': 'E', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 0, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 0, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 0, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 0, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 2, 'y': 0, 'direction': 'E', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 0, (4, 0): 0, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 0, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 0, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 0, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 1, 'y': 0, 'direction': 'E', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 0, (3, 0): 0, (4, 0): 0, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 0, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 0, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 0, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 0, 'y': 0, 'direction': 'E', 'hydradeIndex': {(0, 0): -1, (1, 0): 0, (2, 0): 0, (3, 0): 0, (4, 0): 0, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 0, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 0, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 0, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward']] + #displayControler: NUM_X: 10, NUM_Y: 5 (klasyczne - duże) CHANGE THIS IN DCON !!! + bfsRoot2.reverse() + traktor.move_by_root(bfsRoot2, pole, [traktor.irrigateSlot]) + if(bfs3_flag): + bfsRoot3 = BFS.BFS2({'x': 0, 'y': 0, 'direction': "E"}) + #displayControler: NUM_X: 20, NUM_Y: 12 (skarb) CHANGE THIS IN DCON BY HAND!!!!!!!! + bfsRoot3.reverse() + traktor.move_by_root(bfsRoot3, pole, [traktor.irrigateSlot]) # ui.render_text_to_console(string_to_print="traktor porusza się ścieżką bfs") - traktor.move_by_root(bfsRoot1, pole, [traktor.irrigateSlot]) - #traktor.move_by_root(bfsRoot2, pole, [traktor.irrigateSlot]) - #traktor.move_by_root(bfsRoot3, pole, [traktor.irrigateSlot]) - start_flag=False # demo_move() old_info=get_info(old_info) diff --git a/BFS.py b/BFS.py index 23cb7f3..366bcac 100644 --- a/BFS.py +++ b/BFS.py @@ -1,4 +1,6 @@ import random + +import pygame import Node from displayControler import NUM_X, NUM_Y @@ -84,6 +86,9 @@ def BFS1(istate): x.parent = elem x.action = resp[0] fringe.append(x) + for event in pygame.event.get(): + if event.type == pygame.QUIT: + quit() @@ -159,6 +164,9 @@ def BFS2(istate): x.parent = elem x.action = resp[0] fringe.append(x) + for event in pygame.event.get(): + if event.type == pygame.QUIT: + quit() diff --git a/Slot.py b/Slot.py index 15511dc..cd1e928 100644 --- a/Slot.py +++ b/Slot.py @@ -59,4 +59,12 @@ class Slot: return f"wspolrzedne: (X:{self.x_axis} Y:{self.y_axis}) "+self.plant.report_status() def irrigatePlant(self): self.plant.stan.nawodnienie = 100 + + def setHydrate(self,index): + if(index==0): + self.plant.stan.nawodnienie=random.randint(0,60) + elif(index==1): + self.plant.stan.nawodnienie=random.randint(61,100) + elif(index==-1): + pass \ No newline at end of file diff --git a/Tractor.py b/Tractor.py index 2c0dfe3..2780372 100644 --- a/Tractor.py +++ b/Tractor.py @@ -6,6 +6,11 @@ import Slot import Osprzet import Node +tab = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, + 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] class Tractor: @@ -13,7 +18,7 @@ class Tractor: DIRECTION_SOUTH = 'S' DIRECTION_WEST = 'W' DIRECTION_EAST = 'E' - def __init__(self,slot,screen, osprzet,clock): + def __init__(self,slot,screen, osprzet,clock,bfs2_flag): self.tractor_images = { Tractor.DIRECTION_NORTH: pygame.transform.scale(pygame.image.load('images/traktorN.png'), (dCon.CUBE_SIZE, dCon.CUBE_SIZE)), @@ -31,6 +36,7 @@ class Tractor: self.osprzet = osprzet self.clock=clock self.slot_hydrate_dict={} + self.bfs2_flag=bfs2_flag def draw_tractor(self): @@ -102,13 +108,30 @@ class Tractor: self.do_move_if_valid(pole,(0,0)) def initial_move(self,pole): - for y in range (0,dCon.NUM_Y): - if(y%2==0): - for x in range(0,dCon.NUM_X): - self.snake_move(pole,x,y) - else: - for x in range(dCon.NUM_X,-1,-1): - self.snake_move(pole,x,y) + if (self.bfs2_flag==True): + index=0 + + for y in range (0,dCon.NUM_Y): + if(y%2==0): + for x in range(0,dCon.NUM_X): + if(pole.is_valid_move((x,y))): + pole.get_slot_from_cord((x,y)).setHydrate(tab[index]) + self.snake_move(pole,x,y) + index=index+1 + else: + for x in range(dCon.NUM_X,-1,-1): + if(pole.is_valid_move((x,y))): + pole.get_slot_from_cord((x,y)).setHydrate(tab[index]) + self.snake_move(pole,x,y) + index=index+1 + else: + for y in range (0,dCon.NUM_Y): + if(y%2==0): + for x in range(0,dCon.NUM_X): + self.snake_move(pole,x,y) + else: + for x in range(dCon.NUM_X,-1,-1): + self.snake_move(pole,x,y) def snake_move(self,pole,x,y): diff --git a/displayControler.py b/displayControler.py index f5cb408..1847af2 100644 --- a/displayControler.py +++ b/displayControler.py @@ -1,6 +1,6 @@ CUBE_SIZE = 64 -NUM_X = 6 -NUM_Y = 3 +NUM_X = 10 +NUM_Y = 5 #returns true if tractor can move to specified slot def isValidMove(x, y): -- 2.20.1 From a696da09de8fdbbd34f3cdd229d3d9a889bdac5a Mon Sep 17 00:00:00 2001 From: jakzar Date: Mon, 15 Apr 2024 11:20:47 +0200 Subject: [PATCH 12/12] -Added way to clear console -Support different dimmension of grid for console --- App.py | 23 +++++++++++++++++++---- Ui.py | 18 ++++++++++++++---- displayControler.py | 7 +++++-- 3 files changed, 38 insertions(+), 10 deletions(-) diff --git a/App.py b/App.py index 0fe7caa..93c18ba 100644 --- a/App.py +++ b/App.py @@ -21,8 +21,8 @@ pole=Pole.Pole(screen,image_loader) pole.draw_grid() #musi byc tutaj wywołane ponieważ inicjalizuje sloty do slownika ui=Ui.Ui(screen) #Tractor creation -bfs1_flag=False -bfs2_flag=True #Change this lines to show different bfs implementation +bfs1_flag=True +bfs2_flag=False #Change this lines to show different bfs implementation bfs3_flag=False traktor_slot = pole.get_slot_from_cord((0, 0)) traktor = Tractor.Tractor(traktor_slot, screen, Osprzet.opryskiwacz,clock,bfs2_flag) @@ -41,22 +41,33 @@ def init_demo(): #Demo purpose ui.render_text_to_console(string_to_print="Przejazd inicjalizujacy- traktor sprawdza poziom nawodnienia") traktor.initial_move(pole) traktor.reset_pos(pole) + clock.tick(20) + ui.clear_console() + clock.tick(20) + ui.render_text_to_console("Obliczanie sciezki przy uzyciu BFS") + for event in pygame.event.get(): + if event.type == pygame.QUIT: + quit() if(bfs1_flag): bfsRoot1 = BFS.BFS1({"x": 0, "y": 0, "direction": "E", "hydradeIndex": traktor.slot_hydrate_dict}) #displayControler: NUM_X: 6, NUM_Y: 3 (klasyczne) CHANGE THIS BY HAND bfsRoot1.reverse() + print_to_console("Traktor porusza sie obliczona sciezka BFS") traktor.move_by_root(bfsRoot1, pole, [traktor.irrigateSlot]) if(bfs2_flag): bfsRoot2 = [[{'x': 2, 'y': 2, 'direction': 'N', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 1, (1, 2): 1, (2, 2): 1, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 1, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 2, 'y': 2, 'direction': 'E', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 1, (1, 2): 1, (2, 2): 1, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 1, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'left'], [{'x': 1, 'y': 2, 'direction': 'E', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 1, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 1, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 0, 'y': 2, 'direction': 'E', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 1, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 1, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 0, 'y': 2, 'direction': 'N', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 1, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 1, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'right'], [{'x': 0, 'y': 3, 'direction': 'N', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 1, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 0, 'y': 3, 'direction': 'W', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 1, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'right'], [{'x': 1, 'y': 3, 'direction': 'W', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 1, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 2, 'y': 3, 'direction': 'W', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 1, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 3, 'y': 3, 'direction': 'W', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 1, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 4, 'y': 3, 'direction': 'W', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 4, 'y': 3, 'direction': 'S', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 1, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'right'], [{'x': 4, 'y': 2, 'direction': 'S', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 1, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 0, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 4, 'y': 1, 'direction': 'S', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 0, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 0, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 4, 'y': 0, 'direction': 'S', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 0, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 0, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 0, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 4, 'y': 0, 'direction': 'E', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 1, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 0, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 0, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 0, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'right'], [{'x': 3, 'y': 0, 'direction': 'E', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 1, (4, 0): 0, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 0, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 0, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 0, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 2, 'y': 0, 'direction': 'E', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 1, (3, 0): 0, (4, 0): 0, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 0, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 0, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 0, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 1, 'y': 0, 'direction': 'E', 'hydradeIndex': {(0, 0): -1, (1, 0): 1, (2, 0): 0, (3, 0): 0, (4, 0): 0, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 0, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 0, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 0, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward'], [{'x': 0, 'y': 0, 'direction': 'E', 'hydradeIndex': {(0, 0): -1, (1, 0): 0, (2, 0): 0, (3, 0): 0, (4, 0): 0, (5, 0): 1, (6, 0): 1, (7, 0): 1, (8, 0): 1, (9, 0): 1, (0, 1): 1, (1, 1): 1, (2, 1): 0, (3, 1): 1, (4, 1): 0, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1, (0, 2): 0, (1, 2): 1, (2, 2): 0, (3, 2): 1, (4, 2): 0, (5, 2): 1, (6, 2): 1, (7, 2): 1, (8, 2): 1, (9, 2): 1, (0, 3): 1, (1, 3): 0, (2, 3): 0, (3, 3): 0, (4, 3): 0, (5, 3): 1, (6, 3): 1, (7, 3): 1, (8, 3): 1, (9, 3): 1, (0, 4): 1, (1, 4): 1, (2, 4): 1, (3, 4): 1, (4, 4): 1, (5, 4): 1, (6, 4): 1, (7, 4): 1, (8, 4): 1, (9, 4): 1}}, 'forward']] #displayControler: NUM_X: 10, NUM_Y: 5 (klasyczne - duże) CHANGE THIS IN DCON !!! bfsRoot2.reverse() + print_to_console("Traktor porusza sie obliczona sciezka BFS") traktor.move_by_root(bfsRoot2, pole, [traktor.irrigateSlot]) if(bfs3_flag): bfsRoot3 = BFS.BFS2({'x': 0, 'y': 0, 'direction': "E"}) #displayControler: NUM_X: 20, NUM_Y: 12 (skarb) CHANGE THIS IN DCON BY HAND!!!!!!!! bfsRoot3.reverse() + print_to_console("Traktor porusza sie obliczona sciezka BFS") traktor.move_by_root(bfsRoot3, pole, [traktor.irrigateSlot]) - # ui.render_text_to_console(string_to_print="traktor porusza się ścieżką bfs") + + start_flag=False # demo_move() @@ -71,7 +82,11 @@ def init(demo): init_demo() #TODO: Implement - +def print_to_console(text): + clock.tick(5) + ui.clear_console() + clock.tick(5) + ui.render_text_to_console(text) def demo_move(): current_slot = traktor.slot diff --git a/Ui.py b/Ui.py index c9755cd..e6f5ab7 100644 --- a/Ui.py +++ b/Ui.py @@ -7,7 +7,15 @@ class Ui: def __init__(self,screen): self.screen=screen self.font='freesansbold.ttf' #Feel free to change it :D - self.font_size=int(16) + if(dCon.NUM_Y<7): + self.font_size=int(15) + self.line=20 + self.first_line=20 + if(dCon.NUM_Y>=7): + self.font_size=int(30) + self.line=30 + self.first_line=30 + def render_text(self,string_to_print): font=pygame.font.Font(self.font,self.font_size) text=font.render(string_to_print,True,Colors.BLACK,Colors.WHITE) @@ -18,14 +26,16 @@ class Ui: def render_text_to_console(self,string_to_print): font=pygame.font.Font(self.font,self.font_size) self.break_string_to_console(string_to_print) - line=10 for string in self.to_print: text=font.render(string,True,Colors.BLACK,Colors.WHITE) textRect=text.get_rect() - textRect.center=(dCon.getGameWidth()+350/2,line) + textRect.center=(dCon.getGameWidth()+350/2,self.line) textRect.scale_by(x=350,y=100) self.screen.blit(text,textRect) - line=line+18 + self.line=self.line+self.first_line + def clear_console(self): + self.line=self.first_line + pygame.draw.rect(self.screen,(0,0,0) , pygame.Rect(dCon.returnConsoleCoordinate(), 0, dCon.getConsoleWidth(), dCon.getScreenHeihgt()), 0) def break_string_to_console(self,string_to_print): self.to_print=string_to_print.split(" ") diff --git a/displayControler.py b/displayControler.py index 1847af2..3d774d8 100644 --- a/displayControler.py +++ b/displayControler.py @@ -1,6 +1,6 @@ CUBE_SIZE = 64 -NUM_X = 10 -NUM_Y = 5 +NUM_X = 6 +NUM_Y = 3 #returns true if tractor can move to specified slot def isValidMove(x, y): @@ -14,6 +14,9 @@ def isValidMove(x, y): def getGameWidth(): return NUM_X * CUBE_SIZE +def returnConsoleCoordinate(): + return NUM_X * CUBE_SIZE + -- 2.20.1