Dodano odkrywanie koszy

This commit is contained in:
s475275 2023-03-27 11:15:11 +02:00
parent f3527d2130
commit b55d836f59
2 changed files with 16 additions and 1 deletions

View File

@ -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)

View File

@ -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()