Skip to content

BaseRayEnv

Full path: schola.rllib.env.BaseRayEnv

schola.rllib.env.BaseRayEnv

BaseRayEnv

BaseRayEnv(protocol, simulator, verbosity=0)

Bases: ABC

Abstract base class for Schola RLlib environments.

Provides shared functionality for protocol/simulator management, space initialization, and common properties. Subclasses (RayEnv, RayVecEnv) must implement reset(), step(), and _init_agent_tracking().

This class does NOT inherit from any RLlib environment classes. Subclasses use multiple inheritance to combine BaseRayEnv with their specific RLlib parent (MultiAgentEnv or VectorMultiAgentEnv).

  • Shared Attributes:: protocol: Communication protocol with Unreal Engine simulator: Simulator instance managing Unreal processes id_manager: Manages environment and agent IDs possible_agents: All agents that can exist (static after init) num_envs: Number of parallel environments metadata: Environment metadata (autoreset_mode, etc.) _observation_space, _action_space: Gymnasium spaces _single_observation_space, _single_action_space: Per-agent spaces _single_observation_spaces, _single_action_spaces: Dict of agent spaces

Methods

ItemDescription
initInitialize protocol, simulator, and shared environment infrastructure.
close_extrasClose protocol and stop simulator.
resetReset environment(s).
stepStep environment(s) with actions.

Attributes

ItemDescription
action_spaceAction space (Dict of agent spaces).
max_num_agentsMaximum number of agents that can exist.
num_agentsTotal number of possible agents (ever seen).
observation_spaceObservation space (Dict of agent spaces).
single_action_spaceSingle-agent action space.
single_action_spacesDict mapping agent IDs to action spaces.
single_observation_spaceSingle-agent observation space.
single_observation_spacesDict mapping agent IDs to observation spaces.

Parameters

protocol (BaseRLProtocol)

simulator (BaseSimulator)

verbosity (int)

init

__init__(protocol, simulator, verbosity=0)

Initialize protocol, simulator, and shared environment infrastructure.

Parameters

protocol (BaseRLProtocol)

simulator (BaseSimulator)

verbosity (int)


action_space

action_space: Space | None

Action space (Dict of agent spaces).


close_extras

close_extras(**kwargs)

Close protocol and stop simulator.


max_num_agents

max_num_agents: int

Maximum number of agents that can exist.


num_agents

num_agents: int

Total number of possible agents (ever seen).


observation_space

observation_space: Space | None

Observation space (Dict of agent spaces).


reset

abstractmethod reset(**kwargs)

Reset environment(s).

Signature differs by subclass:

  • RayEnv: reset(, seed: Optional[int], …) -> Tuple[Dict, Dict]
  • RayVecEnv: reset(, seed: Optional[Union[int, List[int]]], …) -> Tuple[List[Dict], List[Dict]]

single_action_space

single_action_space: Space | None

Single-agent action space.


single_action_spaces

single_action_spaces: Dict[str, Space]

Dict mapping agent IDs to action spaces.


single_observation_space

single_observation_space: Space | None

Single-agent observation space.


single_observation_spaces

single_observation_spaces: Dict[str, Space]

Dict mapping agent IDs to observation spaces.


step

abstractmethod step(actions)

Step environment(s) with actions.

Signature differs by subclass:

  • RayEnv: step(actions: Dict) -> Tuple[Dict, Dict[str, float], …]
  • RayVecEnv: step(actions: List[Dict]) -> Tuple[List[Dict], List[Dict[str, float]], …]