mirror of
https://github.com/illiumst/marl-factory-grid.git
synced 2025-05-23 07:16:44 +02:00
cleaned up if else mess simple_factory_getting_dirty.py:47
This commit is contained in:
parent
3045425a60
commit
cc5df76ef7
@ -45,9 +45,14 @@ class GettingDirty(BaseFactory):
|
|||||||
|
|
||||||
def asset_str(agent):
|
def asset_str(agent):
|
||||||
cols = ' '.join([self.slice_strings[j] for j in agent.collisions])
|
cols = ' '.join([self.slice_strings[j] for j in agent.collisions])
|
||||||
if 'agent' in cols: return 'agent_collision'
|
if 'agent' in cols:
|
||||||
return f'agent{agent.i + 1}violation' if (not agent.action_valid or 'level' in cols or 'agent' in cols) \
|
return 'agent_collision'
|
||||||
else (f'agent{agent.i + 1}valid' if self._is_clean_up_action(agent.action) else f'agent{agent.i + 1}')
|
elif not agent.action_valid or 'level' in cols or 'agent' in cols:
|
||||||
|
return f'agent{agent.i + 1}violation'
|
||||||
|
elif self._is_clean_up_action(agent.action):
|
||||||
|
return f'agent{agent.i + 1}valid'
|
||||||
|
else:
|
||||||
|
return f'agent{agent.i + 1}'
|
||||||
|
|
||||||
agents = {f'agent{i+1}': [Entity(asset_str(agent), agent.pos)]
|
agents = {f'agent{i+1}': [Entity(asset_str(agent), agent.pos)]
|
||||||
for i, agent in enumerate(self.agent_states)}
|
for i, agent in enumerate(self.agent_states)}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user