flatland.core.policy module

flatland.core.policy module#

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

Bases: ABC, Generic[EnvironmentT, ObsT, ActT]

Abstract base class for Flatland policies. Used for evaluation.

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

act(observation: ObsT, **kwargs) → ActT[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[ObsT], **kwargs) → Dict[int, ActT][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