class maze.core.agent_deployment.external_core_env.ExternalCoreEnv(context: maze.core.env.environment_context.EnvironmentContext, state_queue: queue.Queue, maze_action_queue: queue.Queue, rollout_done_event: threading.Event, renderer: Optional[maze.core.rendering.renderer.Renderer] = None, kpi_calculator: Optional[maze.core.log_events.kpi_calculator.KpiCalculator] = None)

Acts as a CoreEnv in the env stack in agent deployment scenario.

Designed to be run on a separate thread, alongside the agent deployment running on the main thread.

Hence, the control flow is: External env (like a Unity env) controlling the agent deployment object, which in turn controls this external core env, which controls the execution of rollout loop by suspending it until the next state is available from the agent deployment object.

Wrappers of this env and the agents acting on top of it see it as ordinary CoreEnv, but no actual logic happens here – instead, states and associated info are obtained from the agent deployment running on the main thread, and executions produced by the agents are passed back to the agent deployment.

During the step function, the execution of this thread is suspended while waiting for the next state from the agent deployment.

  • state_queue – Queue this core env uses to get states from agent deployment object

  • maze_action_queue – Queue this core env uses to pass executions back to agent deployment object

  • rollout_done_event – Set by the agent deployment object. Used for detection of the end of rollout period.

  • renderer – If available, what renderer should be associated with the state data (for rendering, plus to be serialized with trajectory data)


(overrides CoreEnv)

Current actor ID set by the agent deployment.

property agent_counts_dict

(overrides CoreEnv)

Agent counts are not known and not needed, as this env is not used for training or any other setup.


(overrides CoreEnv)

No cleanup required.

get_kpi_calculator() → Optional[maze.core.log_events.kpi_calculator.KpiCalculator]

(overrides CoreEnv)

KPI calculator provided by the agent deployment. Might be None if not available.

get_maze_state() → Any

(overrides CoreEnv)

Return the last state obtained from the external env through agent deployment.

get_renderer() → Optional[maze.core.rendering.renderer.Renderer]

(overrides CoreEnv)

Renderer provided by the agent deployment. Might be None if not available.

get_serializable_components() → Dict[str, Any]

(overrides CoreEnv)

No components available.

get_step_events() → Iterable[maze.core.events.event_record.EventRecord]

(overrides EventEnvMixin)

Get all events recorded in the current step from the EventService.


(overrides CoreEnv)

Whether last actor is done, as set by the agent deployment.

reset() → Any

(overrides CoreEnv)

Reset is expected to be run twice – at the beginning and end of external env rollout.

At the beginning, thread execution is suspended until the initial state is available.

At the end of the rollout, just the last state is returned, as there the reset serves the only purpose of notifying the wrappers to do their processing of the previous episode. (Also, no more states are available from the external env at this point.

seed(seed: int)None

(overrides CoreEnv)

No seed required – all operation handled by external env.

set_actor_id(new_value: maze.core.env.structured_env.ActorID)

Hook for the agent deployment to set actor_id before querying execution.

set_is_actor_done(new_value: bool)

Hook for the agent deployment to set the actor_done flag before querying execution.

step(maze_action: Any) → Tuple[Any, Union[float, numpy.ndarray, Any], bool, Dict[Any, Any]]

(overrides CoreEnv)

Relays the execution back to the agent deployment. Then suspends thread execution until

the next state is provided by agent deployment.