Skip to content
Snippets Groups Projects
Commit 45480975 authored by spiglerg's avatar spiglerg
Browse files

fix?

parent 0152dd76
No related branches found
No related tags found
No related merge requests found
......@@ -29,13 +29,13 @@ class EnvAgentStatic(object):
position = attrib()
direction = attrib()
target = attrib()
moving = False
moving = attrib()
def __init__(self, position, direction, target):
def __init__(self, position, direction, target, moving=False):
self.position = position
self.direction = direction
self.target = target
self.moving = False
self.moving = moving
@classmethod
def from_lists(cls, positions, directions, targets):
......
......@@ -460,7 +460,7 @@ class RailEnv(Environment):
def set_full_state_msg(self, msg_data):
data = msgpack.unpackb(msg_data, use_list=False)
self.rail.grid = np.array(data[b"grid"])
self.agents_static = [EnvAgentStatic(d[0], d[1], d[2]) for d in data[b"agents_static"]]
self.agents_static = [EnvAgentStatic(d[0], d[1], d[2], d[3]) for d in data[b"agents_static"]]
self.agents = [EnvAgent(d[0], d[1], d[2], d[3], d[4]) for d in data[b"agents"]]
# setup with loaded data
self.height, self.width = self.rail.grid.shape
......
......@@ -8,7 +8,7 @@ def test_load_env():
env = RailEnv(10, 10)
env.load("env-data/tests/test-10x10.mpk")
agent_static = EnvAgentStatic((0, 0), 2, (5, 5))
agent_static = EnvAgentStatic((0, 0), 2, (5, 5), False)
env.add_agent_static(agent_static)
assert env.get_num_agents() == 1
......
......@@ -185,14 +185,14 @@ def test_dead_end():
# rail_env.agents_target[0] = (0, 0)
# rail_env.agents_position[0] = (0, 2)
# rail_env.agents_direction[0] = 1
rail_env.agents = [EnvAgent(position=(0, 2), direction=1, target=(0, 0))]
rail_env.agents = [EnvAgent(position=(0, 2), direction=1, target=(0, 0), moving=False)]
check_consistency(rail_env)
rail_env.reset()
# rail_env.agents_target[0] = (0, 4)
# rail_env.agents_position[0] = (0, 2)
# rail_env.agents_direction[0] = 3
rail_env.agents = [EnvAgent(position=(0, 2), direction=3, target=(0, 4))]
rail_env.agents = [EnvAgent(position=(0, 2), direction=3, target=(0, 4), moving=False)]
check_consistency(rail_env)
# In the vertical configuration:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment