From b55d836f59571df8d67e07aed2397be63cc6d960 Mon Sep 17 00:00:00 2001 From: s475275 Date: Mon, 27 Mar 2023 11:15:11 +0200 Subject: [PATCH] Dodano odkrywanie koszy --- src/agent.py | 10 ++++++++++ src/simulation.py | 7 ++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/agent.py b/src/agent.py index a63f7d0..60f0fa8 100644 --- a/src/agent.py +++ b/src/agent.py @@ -69,3 +69,13 @@ class Agent: move = possible_moves[randint(0, len(possible_moves)-1)] return move + + def discover(self): + if self.current_pos in self.houses.keys(): + current_house = None + for entity in self.simulation.state.entities: + if entity.entity_type == 'house' and vector_to_tuple(entity.position) == self.current_pos: + current_house = entity + break + if current_house is not None: + self.houses[self.current_pos].discover_bins(current_house.bins) diff --git a/src/simulation.py b/src/simulation.py index b6494f7..8f2375d 100644 --- a/src/simulation.py +++ b/src/simulation.py @@ -64,6 +64,9 @@ class Bin: self.trash_type = trash_type self.fullness = randint(0, 100) + def __str__(self): + return self.trash_type + " bin" + class HouseEntity(Entity): def __init__(self, state, position): @@ -128,7 +131,7 @@ class SimulationState: def update(self, move_agent): for entity in self.entities: - if entity.entity_type is 'truck': + if entity.entity_type == 'truck': entity.move(move_agent) @@ -230,6 +233,8 @@ class Interface: self.move_truck.y = 1 if event.key == pg.K_UP: self.move_truck.y = -1 + if event.key == pg.K_d: + self.agent.discover() def processAgentInput(self): self.move_truck = self.agent.decide_move()