feat: agent independently moves to target
This commit is contained in:
parent
d186c2de5c
commit
b7f186562b
21
app.py
21
app.py
@ -89,10 +89,27 @@ target_x, target_y = 4,8
|
|||||||
#target_x, target_y = 11,11
|
#target_x, target_y = 11,11
|
||||||
|
|
||||||
#WYWOLUJEMY FUNKCJE SZUKAJACA LISTY AKCJI
|
#WYWOLUJEMY FUNKCJE SZUKAJACA LISTY AKCJI
|
||||||
shortest_path = agent.bfs2(target_x, target_y)
|
path = agent.bfs2(target_x, target_y)
|
||||||
print("Najkrótsza ścieżka:", shortest_path)
|
print("Najkrótsza ścieżka:", path)
|
||||||
|
|
||||||
|
def watekDlaSciezkiAgenta():
|
||||||
|
time.sleep(3)
|
||||||
|
while True:
|
||||||
|
if len(path) > 0:
|
||||||
|
element = path.pop(0)
|
||||||
|
print(element)
|
||||||
|
if element =="left":
|
||||||
|
agent.rotate_left()
|
||||||
|
if element =="right":
|
||||||
|
agent.rotate_right()
|
||||||
|
if element =="forward":
|
||||||
|
agent.move_direction()
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
|
||||||
|
watek = threading.Thread(target=watekDlaSciezkiAgenta)
|
||||||
|
watek.daemon = True
|
||||||
|
watek.start()
|
||||||
|
|
||||||
running = True
|
running = True
|
||||||
while running:
|
while running:
|
||||||
|
Loading…
Reference in New Issue
Block a user