import random from src.obj.Object import Object class Table(Object): def __init__(self, position, orientation, square_size, screen_size): super().__init__("table", position, orientation, square_size, screen_size) self.waiting_time = 0 self.cooking_time = 0 self.is_actual = False def isActual(self): return self.is_actual def updateState(self, current_time): if self.is_actual: return self.is_actual = True # here must be neural network choise new_role = random.choice(["table", "order", "wait", "done"]) self.change_role(new_role, current_time) if self.agent_role == "table": return elif self.agent_role == "wait": self.cooking_time = random.randint(0, 300) def dish_is_ready(self, current_time): return current_time - self.waiting_time > self.cooking_time def get_state_number(self) -> int: roles = { "table": 0, "order": 1, "wait": 2, "done": 3 } return roles[self.agent_role] def change_role(self, new_role, current_time): self.waiting_time = current_time return super().change_role(new_role) def reset(self, current_time): self.is_actual = False self.change_role("table", current_time) def set_order(self, current_time): if self.agent_role == "table": self.change_role("order", current_time) def set_wait(self, current_time): if self.agent_role == "order": self.change_role("wait", current_time) def set_done(self, current_time): if self.agent_role == "wait": self.change_role("done", current_time) def is_order(self): return self.agent_role == "order" def is_wait(self): return self.agent_role == "wait" def is_done(self): return self.agent_role == "done" def get_customers_count(self) -> int: return self.customers def get_mood(self, current_time) -> int: # перапісаць if self.agent_role == "table": return 2 # undefined diff = current_time - self.waiting_time return 0 if diff >= 300 else 1 # 0 - bad; 1 - good def action(self, waiter, current_time): if self.is_order(): waiter.collect_order(self, current_time) elif self.is_done(): waiter.deliver_dish(self, current_time)