Properties

This commit is contained in:
steffen-illium
2021-05-12 12:59:40 +02:00
parent 4b24b4f0f2
commit b16f316f08
2 changed files with 35 additions and 7 deletions

View File

@@ -8,6 +8,10 @@ from environments import helpers as h
class BaseFactory:
@property
def movement_actions(self):
return (int(self.allow_vertical_movement) + int(self.allow_horizontal_movement)) * 4
def __init__(self, level='simple', n_agents=1, max_steps=1e3):
self.n_agents = n_agents
self.max_steps = max_steps
@@ -64,8 +68,7 @@ class BaseFactory:
return self.state, r, self.done, info
def _is_moving_action(self, action):
movement_actions = (int(self.allow_vertical_movement) + int(self.allow_horizontal_movement)) * 4
if action < movement_actions:
if action < self.movement_actions:
return True
else:
return False
@@ -106,6 +109,9 @@ class BaseFactory:
# Agent seems to be trying to collide in this step
return old_pos, valid
def agent_i_position(self, agent_i):
return np.argwhere(self.state[h.AGENT_START_IDX+agent_i] == h.IS_OCCUPIED_CELL)
@property
def free_cells(self) -> np.ndarray:
free_cells = self.state.sum(0)