diff --git a/App.py b/App.py index 1f0fd48..68aa702 100644 --- a/App.py +++ b/App.py @@ -46,7 +46,7 @@ def init_demo(): #Demo purpose while True: clock.tick(FPS) if(start_flag): - ui.render_text_to_console(string_to_print="Przejazd inicjalizujacy- traktor sprawdza poziom nawodnienia") + #ui.render_text_to_console(string_to_print="Przejazd inicjalizujacy- traktor sprawdza poziom nawodnienia") if not bfs1_flag: time.sleep(2) else: @@ -55,7 +55,7 @@ def init_demo(): #Demo purpose clock.tick(20) ui.clear_console() clock.tick(20) - ui.render_text_to_console("Obliczanie sciezki przy uzyciu BFS") + #ui.render_text_to_console("Obliczanie sciezki przy uzyciu BFS") for event in pygame.event.get(): if event.type == pygame.QUIT: quit() @@ -63,7 +63,7 @@ def init_demo(): #Demo purpose 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") + #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']] diff --git a/Condition.py b/Condition.py index 2223c89..07e321e 100644 --- a/Condition.py +++ b/Condition.py @@ -44,4 +44,4 @@ class Condition: def getCondition(self): - print(f"Aktualny czas: {Climate.time[self.currentTime]},opady: {Climate.rain[self.rain]},temperatura: {Climate.temperature[self.temperature]}, pora roku: {Climate.seasons[self.season]}") + return ([Climate.temperature[self.temperature],Climate.rain[self.rain],Climate.seasons[self.season],Climate.time[self.currentTime]]) diff --git a/Drzewo.py b/Drzewo.py index 5cc95ca..761e61c 100644 --- a/Drzewo.py +++ b/Drzewo.py @@ -23,6 +23,6 @@ class Drzewo: def makeDecision(self,values): action=self.tree.predict([values]) #0- nie podlewac, 1-podlewac if(action==[0]): - return "Nie podlewac" + return "Nie" if(action==[1]): - return "Podlewac" \ No newline at end of file + return "Tak" \ No newline at end of file diff --git a/Roslina.py b/Roslina.py index b63acb7..133c8bd 100644 --- a/Roslina.py +++ b/Roslina.py @@ -117,4 +117,7 @@ class Roslina: 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 + return f"Nazwa rosliny: {self.nazwa} "+self.stan.report_all() + + def return_status_tree(self): + return self.stan.return_stan_for_tree() \ No newline at end of file diff --git a/Stan.py b/Stan.py index d64047a..ce3e733 100644 --- a/Stan.py +++ b/Stan.py @@ -62,4 +62,5 @@ class Stan: return [self.nawodnienie,self.wzrost,self.choroba,self.zyznosc] def report_all(self): - return f"Nawodnienie: {self.nawodnienie} Zyznosc: {self.zyznosc} Wzrost: {self.wzrost} Choroba: {self.return_disease_as_string()}" \ No newline at end of file + return f"Nawodnienie: {self.nawodnienie} Zyznosc: {self.zyznosc} Wzrost: {self.wzrost} Choroba: {self.return_disease_as_string()}" + diff --git a/Tractor.py b/Tractor.py index a4276fe..d154ffa 100644 --- a/Tractor.py +++ b/Tractor.py @@ -13,6 +13,8 @@ import Drzewo condition=Condition.Condition() drzewo=Drzewo.Drzewo() +format_string = "{:<25}{:<25}{:<25}{:<10}{:<10}{:<10}{:<25}{:<15}{:<20}{:<10}{:<15}" + tab = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, @@ -65,17 +67,22 @@ class Tractor: def tree_move(self, pole): drzewo.treeLearn() - print("test") drzewo.plotTree() + self.snake_move_irrigation(pole, drzewo) + + def get_attributes(self): slot_attributes=self.slot.return_stan_for_tree() climate_attributes=condition.return_condition() attributes=[] attributes=attributes+slot_attributes+[self.waterLevel]+climate_attributes - print("Decyzja czy podlac:",drzewo.makeDecision(attributes),"Atrybuty tego stanu to:",attributes) - self.snake_move_irrigation(pole, drzewo) - #TODO SNAKE MOVE AND USING drzewo.makeDecision(attributes)for each slot. Also we need to cycle climate for each slot change - #condition.cycle() - #condition.getCondition() + return attributes + + def get_attributes_for_print(self): + slot_attributes=self.slot.return_plant().return_status_tree() + climate_attributes=condition.getCondition() + slot_attributes=slot_attributes+[self.waterLevel] + return slot_attributes+climate_attributes + def turn_right(self): # zmiana kierunku w prawo direction_map = { @@ -157,16 +164,15 @@ class Tractor: def snake_move_irrigation(self, pole, drzewo): + headers=['Wspolrzedne','Czy podlac','Poziom nawodnienia','Wzrost','Choroba','Zyznosc','Poziom wody w traktorze','Temperatura','Opady','Pora Roku','Aktualny czas'] + print(format_string.format(*headers)) initPos = (self.slot.x_axis, self.slot.y_axis) counter = 0 for i in range(initPos[1], dCon.NUM_Y): for j in range(initPos[0], dCon.NUM_X): - slot_attributes=self.slot.return_stan_for_tree() - climate_attributes=condition.return_condition() - attributes=[] - attributes=attributes+slot_attributes+[self.waterLevel]+climate_attributes + attributes=self.get_attributes() decision = drzewo.makeDecision(attributes) - print("Slot:", str("({:02d}, {:02d})").format(self.slot.x_axis, self.slot.y_axis),"Decyzja czy podlac:",decision,"Atrybuty slotu:",attributes) + self.pretty_print_tree([str("({:02d}, {:02d})").format(self.slot.x_axis, self.slot.y_axis),decision,*self.get_attributes_for_print()]) if decision == "Podlewac": self.slot.irrigatePlant() counter += 1 @@ -181,6 +187,7 @@ class Tractor: self.turn_left() self.move_forward(pole, False) self.turn_left() + pygame.time.delay(50) print("podlanych slotów: ", str(counter)) def snake_move(self,pole,x,y): @@ -227,9 +234,11 @@ class Tractor: print("- Typ:", akcja.typ) else: print("Brak akcji przypisanych do tego sprzętu.") + + def pretty_print_tree(self,attributes): + print(format_string.format(*attributes)) def irrigateSlot(self): try: self.slot.irrigatePlant() except: pass -