Dodano odkrywanie koszy
This commit is contained in:
parent
f3527d2130
commit
b55d836f59
10
src/agent.py
10
src/agent.py
@ -69,3 +69,13 @@ class Agent:
|
|||||||
|
|
||||||
move = possible_moves[randint(0, len(possible_moves)-1)]
|
move = possible_moves[randint(0, len(possible_moves)-1)]
|
||||||
return move
|
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)
|
||||||
|
@ -64,6 +64,9 @@ class Bin:
|
|||||||
self.trash_type = trash_type
|
self.trash_type = trash_type
|
||||||
self.fullness = randint(0, 100)
|
self.fullness = randint(0, 100)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.trash_type + " bin"
|
||||||
|
|
||||||
|
|
||||||
class HouseEntity(Entity):
|
class HouseEntity(Entity):
|
||||||
def __init__(self, state, position):
|
def __init__(self, state, position):
|
||||||
@ -128,7 +131,7 @@ class SimulationState:
|
|||||||
|
|
||||||
def update(self, move_agent):
|
def update(self, move_agent):
|
||||||
for entity in self.entities:
|
for entity in self.entities:
|
||||||
if entity.entity_type is 'truck':
|
if entity.entity_type == 'truck':
|
||||||
entity.move(move_agent)
|
entity.move(move_agent)
|
||||||
|
|
||||||
|
|
||||||
@ -230,6 +233,8 @@ class Interface:
|
|||||||
self.move_truck.y = 1
|
self.move_truck.y = 1
|
||||||
if event.key == pg.K_UP:
|
if event.key == pg.K_UP:
|
||||||
self.move_truck.y = -1
|
self.move_truck.y = -1
|
||||||
|
if event.key == pg.K_d:
|
||||||
|
self.agent.discover()
|
||||||
|
|
||||||
def processAgentInput(self):
|
def processAgentInput(self):
|
||||||
self.move_truck = self.agent.decide_move()
|
self.move_truck = self.agent.decide_move()
|
||||||
|
Loading…
Reference in New Issue
Block a user