Skip to content
Snippets Groups Projects
Commit 2a500b3a authored by Egli Adrian (IT-SCI-API-PFI)'s avatar Egli Adrian (IT-SCI-API-PFI)
Browse files

added a print.out question : why will an agent not move, once he reach it's...

added a print.out question : why will an agent not move, once he reach it's destination? May he have to move for passing
parent df3577f2
No related branches found
No related tags found
No related merge requests found
...@@ -138,9 +138,12 @@ class Demo: ...@@ -138,9 +138,12 @@ class Demo:
for step in range(max_nbr_of_steps): for step in range(max_nbr_of_steps):
# Action # Action
for a in range(self.env.get_num_agents()): for iAgent in range(self.env.get_num_agents()):
action = 2 # np.random.choice(self.action_size) #self.agent.act(agent_obs[a]) action = 2
action_dict.update({a: action}) agent = self.env.agents.copy()[iAgent]
if not self.env.check_action(agent, action)[1]:
action = np.random.choice(self.action_size)
action_dict.update({iAgent: action})
self.renderer.renderEnv(show=True, action_dict=action_dict) self.renderer.renderEnv(show=True, action_dict=action_dict)
...@@ -172,7 +175,6 @@ if False: ...@@ -172,7 +175,6 @@ if False:
demo_002.run_demo() demo_002.run_demo()
demo_002 = None demo_002 = None
demo_flatland_000 = Demo(Scenario_Generator.load_scenario('./env-data/railway/example_flatland_000.pkl')) demo_flatland_000 = Demo(Scenario_Generator.load_scenario('./env-data/railway/example_flatland_000.pkl'))
demo_flatland_000.renderer.resize() demo_flatland_000.renderer.resize()
demo_flatland_000.run_demo(1800) demo_flatland_000.run_demo(1800)
......
...@@ -4,7 +4,6 @@ from itertools import starmap ...@@ -4,7 +4,6 @@ from itertools import starmap
import numpy as np import numpy as np
# from flatland.envs.rail_env import RailEnv # from flatland.envs.rail_env import RailEnv
@attrs @attrs
class EnvDescription(object): class EnvDescription(object):
n_agents = attrib() n_agents = attrib()
......
...@@ -4,14 +4,18 @@ Definition of the RailEnv environment and related level-generation functions. ...@@ -4,14 +4,18 @@ Definition of the RailEnv environment and related level-generation functions.
Generator functions are functions that take width, height and num_resets as arguments and return Generator functions are functions that take width, height and num_resets as arguments and return
a GridTransitionMap object. a GridTransitionMap object.
""" """
import numpy as np ### TODO _ this is a global method --> utils or remove later
from inspect import currentframe
import msgpack import msgpack
import numpy as np
from flatland.core.env import Environment from flatland.core.env import Environment
from flatland.envs.observations import TreeObsForRailEnv
from flatland.envs.generators import random_rail_generator
from flatland.envs.env_utils import get_new_position
from flatland.envs.agent_utils import EnvAgentStatic, EnvAgent from flatland.envs.agent_utils import EnvAgentStatic, EnvAgent
from flatland.envs.env_utils import get_new_position
from flatland.envs.generators import random_rail_generator
from flatland.envs.observations import TreeObsForRailEnv
# from flatland.core.transitions import Grid8Transitions, RailEnvTransitions # from flatland.core.transitions import Grid8Transitions, RailEnvTransitions
# from flatland.core.transition_map import GridTransitionMap # from flatland.core.transition_map import GridTransitionMap
...@@ -111,7 +115,7 @@ class RailEnv(Environment): ...@@ -111,7 +115,7 @@ class RailEnv(Environment):
self.agents_static = [None] * number_of_agents # static agent information self.agents_static = [None] * number_of_agents # static agent information
self.num_resets = 0 self.num_resets = 0
self.reset() self.reset()
self.num_resets = 0 # yes, set it to zero again! self.num_resets = 0 # yes, set it to zero again!
self.valid_positions = None self.valid_positions = None
...@@ -197,6 +201,8 @@ class RailEnv(Environment): ...@@ -197,6 +201,8 @@ class RailEnv(Environment):
continue continue
if self.dones[iAgent]: # this agent has already completed... if self.dones[iAgent]: # this agent has already completed...
print("rail_env.py @", currentframe().f_back.f_lineno, " agent ", iAgent,
"has already completed : why action will not be executed!!!!? ADRIAN")
continue continue
action = action_dict[iAgent] action = action_dict[iAgent]
......
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