Skip to content

OakEmuEnv ​

python
OakEmuEnv(game_configuration: GameConfiguration, model_configuration: ModelConfiguration, training_configuration: TrainingConfiguration | None, observation_shape_order: Literal['hwf', 'fhw'], training_mode: TrainingMode = TrainingMode.TRAINING, render_mode: Literal['rgb_array'] | None = None, dump_directory: str | PathLike | None = None) -> None

Initialize the OakEmuEnv.

Parameters:

  • game_configuration (GameConfiguration) – The game configuration.
  • model_configuration (ModelConfiguration) – The model configuration.
  • observation_shape_order (Literal['hwf', 'fhw']) – The order of dimensions in the observation shape.
  • training_mode (TrainingMode) – The training mode.
  • render_mode (Literal['rgb_array'] | None) – Optional rendering mode.
  • dump_directory (str | PathLike | None) – Optional directory for environment dumps.

Source

Properties ​

action_shape ​

python
action_shape: int

Get the size of the action space.

Returns:

  • int – The number of discrete actions.

Source

observation_shape ​

python
observation_shape: tuple[int, int, int]

Get the observation shape.

Returns:

  • tuple[int, int, int] – The shape of the observations.

Source

spectrum ​

python
spectrum: ZXSpectrum

Get the underlying ZXSpectrum instance.

Returns:

  • ZXSpectrum – The ZXSpectrum instance.

Source

training_mode ​

python
training_mode: TrainingMode

Get the training mode.

Returns:

  • TrainingMode – The training mode.

Source

Methods ​

get_integer_data ​

python
get_integer_data(name: str) -> int

Retrieve custom integer data from the environment.

Parameters:

  • name (str) – The name of the data field.

Returns:

  • int – The integer value.

Source

render ​

python
render() -> gym.core.RenderFrame | list[gym.core.RenderFrame] | None

Render the current state of the environment.

Returns:

  • RenderFrame | list[RenderFrame] | None – The rendered frame, or None if render_mode is not set.

Source

reset ​

python
reset(*, seed: int | None = None, options: dict[str, Any] | None = None, initial_state: bytes | None = None) -> tuple[np.ndarray, dict[str, Any]]

Reset the environment.

Parameters:

  • seed (int | None) – Optional random seed.
  • options (dict[str, Any] | None) – Optional reset options.
  • initial_state (bytes | None) – Optional serialised emulator state to reset from.

Returns:

  • tuple[ndarray, dict[str, Any]] – A tuple containing the initial observation and an empty info dictionary.

Source

serialize_state ​

python
serialize_state() -> bytes

Serialise the emulator's current machine state.

The bytes are the same form a snapshot restart restores from (reset(initial_state=...)), so a state captured mid-replay can seed a midpoint restart later.

Returns:

  • bytes – The serialised machine state.

Source

step ​

python
step(action: int | np.integer) -> tuple[np.ndarray, float, bool, bool, dict[str, Any]]

Perform an action in the environment.

Parameters:

  • action (int | integer) – The action to perform.

Returns:

  • tuple[ndarray, float, bool, bool, dict[str, Any]] – A tuple of (observation, reward, terminated, truncated, info).

Source

Values ​

action_space ​

python
action_space: gym.spaces.Discrete = gym.spaces.Discrete(self._environment.ActionSpace)

Source

metadata ​

python
metadata = {'observation_shape_orders': ['hwf', 'fhw'], 'render_modes': ['rgb_array'], 'render_fps': float(DotNetDecimal.ToDouble(DotNetZXSpectrum.FrameRate))}

Source

observation_space ​

python
observation_space: gym.spaces.Box = gym.spaces.Box(low=self._environment.ObservationSpace.Low, high=self._environment.ObservationSpace.High, dtype=dot_net_type_to_dtype(self._environment.ObservationSpace.Type).type, shape=self._observation_shape)

Gymnasium environment for OakEmu.

Source

render_mode ​

python
render_mode = render_mode

Source