flatland.action_plan.action_plan module

class flatland.action_plan.action_plan.ActionPlanElement(scheduled_at, action)

Bases: tuple

action

Alias for field number 1

scheduled_at

Alias for field number 0

class flatland.action_plan.action_plan.ControllerFromTrainruns(env: flatland.envs.rail_env.RailEnv, trainrun_dict: Dict[int, List[flatland.envs.rail_trainrun_data_structures.TrainrunWaypoint]])[source]

Bases: object

Takes train runs, derives the actions from it and re-acts them.

act(self, current_step:int) → Dict[int, flatland.envs.rail_env.RailEnvActions][source]

Get the action dictionary to be replayed at the current step. Returns only action where required (no action for done agents or those not at the beginning of the cell).

ASSUMPTION we assume the env has remove_agents_at_target=True and activate_agents=False!!

Parameters:
current_step: int
Returns:
Dict[int, RailEnvActions]
static assert_actions_plans_equal(expected_action_plan:Dict[int, List[flatland.action_plan.action_plan.ActionPlanElement]], actual_action_plan:Dict[int, List[flatland.action_plan.action_plan.ActionPlanElement]])[source]
get_action_at_step(self, agent_id:int, current_step:int) → Union[flatland.envs.rail_env.RailEnvActions, NoneType][source]

Get the current action if any is defined in the ActionPlan. ASSUMPTION we assume the env has remove_agents_at_target=True and activate_agents=False!!

Parameters:
agent_id
current_step
Returns:
WalkingElement, optional
get_waypoint_before_or_at_step(self, agent_id:int, step:int) → flatland.envs.rail_trainrun_data_structures.Waypoint[source]

Get the way point point from which the current position can be extracted.

Parameters:
agent_id
step
Returns:
WalkingElement
pp = <pprint.PrettyPrinter object>
print_action_plan(self)[source]

Pretty-prints ActionPlanDict of this ControllerFromTrainruns to stdout.

static print_action_plan_dict(action_plan:Dict[int, List[flatland.action_plan.action_plan.ActionPlanElement]])[source]

Pretty-prints ActionPlanDict to stdout.