Skip to content

Agent ​

python
Agent(context: RuntimeContext[ConfigT], action_selector: ActionSelector, inference_batch_size: int = 1, env_factory: Callable[[], OakEmuMultiEnv] | None = None) -> None

ABC for environment-interacting components.

Provides shared infrastructure for episode outcome tracking, metrics logging, and environment lifecycle management. Subclassed by Trainer (data collection) and Tester (greedy evaluation).

Initialize the Agent.

Parameters:

  • context (RuntimeContext[[Agent[ConfigT]](#mrkwatkins.oakemu_rl.framework.agents.Agent.Agent[ConfigT])]) – The shared runtime context.
  • action_selector (ActionSelector) – The action selector for choosing actions.
  • inference_batch_size (int) – Number of results to collect before running batched inference.
  • env_factory (Callable[[], OakEmuMultiEnv] | None) – Optional factory for the multi-environment, used by run(). Defaults to _default_env_factory, which builds a real OakEmuMultiEnv; tests can inject a factory returning a fake instead.

Source

Properties ​

action_masker ​

python
action_masker: ActionMasker

Get the action masker.

Returns:

  • ActionMasker – The ActionMasker instance.

Source

action_selector ​

python
action_selector: ActionSelector

Get the action selector used for action selection.

Returns:

  • ActionSelector – The ActionSelector instance.

Source

config ​

python
config: ConfigT

Get the experiment configuration.

Returns:

  • [Agent[ConfigT]](#mrkwatkins.oakemu_rl.framework.agents.Agent.Agent[ConfigT]) – The experiment configuration instance.

Source

metrics ​

python
metrics: MetricsTracker

Get the metrics tracker.

Returns:

  • MetricsTracker – The MetricsTracker instance.

Source

result_queue_depth ​

python
result_queue_depth: int

Get the current depth of the underlying environment result queue.

Returns:

  • int – The queue depth, or 0 if the environment has not started yet.

Source

total_episodes ​

python
total_episodes: int

Get the total number of episodes completed.

Returns:

  • int – The total episode count.

Source

total_losses ​

python
total_losses: int

Get the total number of losses.

Returns:

  • int – The total loss count.

Source

total_truncated ​

python
total_truncated: int

Get the total number of truncated episodes.

Returns:

  • int – The total truncated count.

Source

total_wins ​

python
total_wins: int

Get the total number of wins.

Returns:

  • int – The total win count.

Source

Methods ​

restore_state ​

python
restore_state(state: AgentEpisodeTotalsState) -> None

Restore the episode counters from checkpointed runtime state.

Parameters:

  • state (AgentEpisodeTotalsState) – The episode totals to restore.

Source

run ​

python
run() -> None

Main loop for the agent.

Source