mirror of
https://github.com/illiumst/marl-factory-grid.git
synced 2025-06-18 18:52:52 +02:00
added target agent test and fixed tsp agents
This commit is contained in:
@ -11,10 +11,11 @@ class TSPDirtAgent(TSPBaseAgent):
|
||||
super(TSPDirtAgent, self).__init__(*args, **kwargs)
|
||||
|
||||
def predict(self, *_, **__):
|
||||
if self._env.state[di.DIRT].by_pos(self.state.pos) is not None:
|
||||
dirt_at_position = self._env.state[di.DIRT].by_pos(self.state.pos)
|
||||
if dirt_at_position:
|
||||
# Translate the action_object to an integer to have the same output as any other model
|
||||
action = di.CLEAN_UP
|
||||
elif door := self._door_is_close(self._env):
|
||||
elif door := self._door_is_close(self._env.state):
|
||||
action = self._use_door_or_move(door, di.DIRT)
|
||||
else:
|
||||
action = self._predict_move(di.DIRT)
|
||||
|
@ -18,13 +18,15 @@ class TSPItemAgent(TSPBaseAgent):
|
||||
self.mode = mode
|
||||
|
||||
def predict(self, *_, **__):
|
||||
if self._env.state[i.ITEM].by_pos(self.state.pos) is not None:
|
||||
item_at_position = self._env.state[i.ITEM].by_pos(self.state.pos)
|
||||
dropoff_at_position = self._env.state[i.DROP_OFF].by_pos(self.state.pos)
|
||||
if item_at_position:
|
||||
# Translate the action_object to an integer to have the same output as any other model
|
||||
action = i.ITEM_ACTION
|
||||
elif self._env.state[i.DROP_OFF].by_pos(self.state.pos) is not None:
|
||||
elif dropoff_at_position:
|
||||
# Translate the action_object to an integer to have the same output as any other model
|
||||
action = i.ITEM_ACTION
|
||||
elif door := self._door_is_close(self._env):
|
||||
elif door := self._door_is_close(self._env.state):
|
||||
action = self._use_door_or_move(door, i.DROP_OFF if self.mode == MODE_BRING else i.ITEM)
|
||||
else:
|
||||
action = self._choose()
|
||||
|
@ -20,7 +20,7 @@ class TSPTargetAgent(TSPBaseAgent):
|
||||
return None
|
||||
|
||||
def predict(self, *_, **__):
|
||||
if door := self._door_is_close(self._env):
|
||||
if door := self._door_is_close(self._env.state):
|
||||
action = self._use_door_or_move(door, d.DESTINATION)
|
||||
else:
|
||||
action = self._predict_move(d.DESTINATION)
|
||||
|
Reference in New Issue
Block a user