updated stuff

This commit is contained in:
romue 2021-05-07 14:01:59 +02:00
parent 6eb97e20b1
commit 3c86684586
2 changed files with 11 additions and 1 deletions

View File

@ -31,7 +31,8 @@ class Factory(object):
actions = [actions] actions = [actions]
# level, agent 1,..., agent n, # level, agent 1,..., agent n,
for i, a in enumerate(actions): for i, a in enumerate(actions):
h.check_agent_move(state=self.state, dim=i+1, action=a) old_pos, new_pos, valid = h.check_agent_move(state=self.state, dim=i+1, action=a)
if __name__ == '__main__': if __name__ == '__main__':
factory = Factory(n_agents=1) factory = Factory(n_agents=1)

View File

@ -28,6 +28,7 @@ def check_agent_move(state, dim, action):
raise AssertionError('Only one agent per slice is allowed.') raise AssertionError('Only one agent per slice is allowed.')
x, y = agent_pos[0] x, y = agent_pos[0]
x_new, y_new = x, y x_new, y_new = x, y
# Actions
if action == 0: # North if action == 0: # North
x_new -= 1 x_new -= 1
elif action == 1: # East elif action == 1: # East
@ -48,6 +49,14 @@ def check_agent_move(state, dim, action):
elif action == 7: # NW elif action == 7: # NW
x_new -= 1 x_new -= 1
y_new -= 1 y_new -= 1
# Check validity
valid = (x_new < 0 or y_new < 0
or x_new >= agent_slice.shape[0]
or y_new >= agent_slice.shape[0]
)
return (x, y), (x_new, y_new), valid