mirror of
https://github.com/illiumst/marl-factory-grid.git
synced 2025-11-02 21:47:25 +01:00
Movement printing and Results, state, state reset.
This commit is contained in:
@@ -19,5 +19,5 @@ class DestAction(Action):
|
||||
state.print(f'{entity.name} just waited at {entity.pos}')
|
||||
else:
|
||||
valid = c.NOT_VALID
|
||||
state.print(f'{entity.name} just tried to do_wait_action do_wait_action at {entity.pos} but failed')
|
||||
state.print(f'{entity.name} just tried to "do_wait_action" at {entity.pos} but failed')
|
||||
return self.get_result(valid, entity)
|
||||
|
||||
@@ -70,6 +70,10 @@ class Inventory(IsBoundMixin, Collection):
|
||||
def set_collection(self, collection):
|
||||
self._collection = collection
|
||||
|
||||
def clear_temp_state(self):
|
||||
# Entites need this, but inventories have no state....
|
||||
pass
|
||||
|
||||
|
||||
class Inventories(Objects):
|
||||
_entity = Inventory
|
||||
|
||||
@@ -26,16 +26,22 @@ class Maintainer(Entity):
|
||||
self._last_serviced = 'None'
|
||||
|
||||
def tick(self, state):
|
||||
self.clear_temp_state
|
||||
if found_objective := h.get_first(state[self.objective].by_pos(self.pos)):
|
||||
if found_objective.name != self._last_serviced:
|
||||
self.action.do(self, state)
|
||||
self._last_serviced = found_objective.name
|
||||
else:
|
||||
action = self.get_move_action(state)
|
||||
return action.do(self, state)
|
||||
result = action.do(self, state)
|
||||
else:
|
||||
action = self.get_move_action(state)
|
||||
return action.do(self, state)
|
||||
result = action.do(self, state)
|
||||
self.set_state(result)
|
||||
return result
|
||||
|
||||
def set_state(self, action_result):
|
||||
self._status = action_result
|
||||
|
||||
def get_move_action(self, state) -> Action:
|
||||
if self._path is None or not len(self._path):
|
||||
|
||||
Reference in New Issue
Block a user