Moving to beerKeg or coffeeMachine and back

This commit is contained in:
Kosterix08 2024-06-12 13:03:08 +02:00
parent 1be5d0fe09
commit dd2d0616f3
2 changed files with 37 additions and 7 deletions

40
app.py
View File

@ -104,6 +104,9 @@ target_x, target_y = klientx_target-1, klienty_target
def watekDlaSciezkiAgenta():
assigned = False
has_visited_beer_keg = False
has_visited_coffee = False
adult = False
time.sleep(3)
while True:
if len(path) > 0:
@ -119,9 +122,11 @@ def watekDlaSciezkiAgenta():
x, y = element
agent.moveto(x, y)
neighbors = agent.get_neighbors(agent.current_cell, agent.cells)
for neighbor in neighbors:
if neighbor == klient.current_cell:
if not assigned:
neighbors = agent.get_neighbors(agent.current_cell, agent.cells)
for neighbor in neighbors:
if neighbor == klient.current_cell:
if not assigned:
random_client_data = random.choice(clients)
glasses = predict_image(random_client_data.zdjecie)
@ -130,10 +135,33 @@ def watekDlaSciezkiAgenta():
print(random_client_data)
print("Prediction (Adult):", prediction)
assigned = True
break
if assigned:
break
if prediction == "Yes":
path_beer = agent.bfs2(6,6)
if path_beer:
path.extend(path_beer)
elif prediction == "No":
path_coffee = agent.bfs2(4,10)
if path_coffee:
path.extend(path_coffee)
if assigned:
if prediction == "Yes":
if not has_visited_beer_keg:
if agent.current_cell == cells[6][6]:
has_visited_beer_keg = True
move_back = agent.bfs2(target_x,target_y)
if move_back:
path.extend(move_back)
elif prediction == "No":
if not has_visited_coffee:
if agent.current_cell == cells[4][10]:
has_visited_coffee = True
move_back = agent.bfs2(target_x,target_y)
if move_back:
path.extend(move_back)
time.sleep(1)

View File

@ -9,6 +9,8 @@ class Agent:
self.sprite = pygame.image.load("sprites/BartenderNew64.png").convert_alpha()
self.sprite = pygame.transform.scale(self.sprite, (prefs.CELL_SIZE, prefs.CELL_SIZE))
self.current_cell = cells[x][y]
self_current_x = x
self_current_y = y
self.moved=False
self.last_move_time = pygame.time.get_ticks()
self.last_interact_time = pygame.time.get_ticks()