diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index c7dcbe6..95a134d 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -1,7 +1,12 @@
-
+
+
+
+
+
+
@@ -15,9 +20,14 @@
+
+
+
+
+
@@ -98,14 +108,27 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/__pycache__/functions.cpython-37.pyc b/__pycache__/functions.cpython-37.pyc
index 6677df7..76f91aa 100644
Binary files a/__pycache__/functions.cpython-37.pyc and b/__pycache__/functions.cpython-37.pyc differ
diff --git a/functions.py b/functions.py
index c18a05d..f4c5fb7 100644
--- a/functions.py
+++ b/functions.py
@@ -67,6 +67,7 @@ def a_star(start_field, goal_field, board):
field.g = 0
field.h = 0
field.f = 0
+ field.previous = None
return path
@@ -133,4 +134,16 @@ def change_turn(agent, next_field):
agent.turn_right()
-
+# def execute_step(agent, next_step, board, path):
+# if check_turn(agent, next_step):
+# agent.move_forward(board)
+# if len(path) != 0:
+# next_step = path.pop()
+# else:
+# next_step = None
+# for row in board:
+# for field in row:
+# if not field.is_shelf:
+# field.image = pygame.image.load('img/Field.png')
+# else:
+# change_turn(agent, next_step)
diff --git a/main.py b/main.py
index fcd7be7..63bd66d 100644
--- a/main.py
+++ b/main.py
@@ -6,6 +6,7 @@ import time
from agent import Agent
from settings import Settings
from board import create_board, draw_board
+from random import randint
# Inicjalizacja programu i utworzenie obiektu ekrany
@@ -21,9 +22,8 @@ def run():
for field in row:
print(field.cost_of_travel)
- path = functions.a_star(board[agent.y][agent.x], board[5][7], board)
- path.pop(len(path) - 1)
- next_step = path.pop(len(path) - 1)
+ path = []
+ next_step = None
# Rozpoczęcie głównej pętli programu
while True:
# functions.check_events(agent, board)
@@ -39,18 +39,34 @@ def run():
agent.turn_left()
elif event.key == pygame.K_UP:
agent.move_forward(board)
+ print(agent.x, agent.y)
+ elif event.key == pygame.K_SPACE:
+ field = board[randint(0, 9)][randint(0, 9)]
+ if not field.is_shelf:
+ path = functions.a_star(board[agent.y][agent.x], field, board)
+ path.pop(len(path) - 1)
+ next_step = path.pop(len(path) - 1)
- if len(path) >= 0:
+ if next_step is not None:
time.sleep(0.5)
+
if functions.check_turn(agent, next_step):
agent.move_forward(board)
if len(path) != 0:
next_step = path.pop()
+ else:
+ next_step = None
+ print(next_step, path)
+ for row in board:
+ for field in row:
+ if not field.is_shelf:
+ field.image = pygame.image.load('img/Field.png')
+ for row in board:
+ for field in row:
+ print(field.g, field.h, field.f, field.previous)
else:
functions.change_turn(agent, next_step)
- print(agent.position_x, agent.position_y)
-
-
+ print(agent.x, agent.y)
draw_board(board)
agent.blitme()