flatland.core.policy module

flatland.core.policy module#

class flatland.core.policy.Policy[source]#

Bases: ABC, Generic[T_env, T_obs, T_act]

Abstract base class for Flatland policies. Used for evaluation.

Loosely corresponding to ray-project/ray, but much simpler.

act(observation: List[T_obs], **kwargs) T_act[source]#

Get action for agent. Called by act_many() for each agent.

Parameters#

observation: Any

the agent’s observation

kwargs

forward compatibility placeholder

Returns#

Any

the action dict

act_many(handles: List[int], observations: List[T_obs], **kwargs) Dict[int, T_act][source]#

Get action_dict for all agents. Default implementation calls act() for each handle in the list.

Override if you need to initialize before / cleanup after calling act() for individual agents.

Parameters#

handles: List[int]

the agents’ handles

observations: List[Any]

the agents’ observations

kwargs

forward compatibility placeholder

Returns#

Dict[int, Any]

the action dict