gameboy_worlds.interface.survival_kids.environments

 1from gameboy_worlds.emulation.emulator import Emulator
 2from gameboy_worlds.emulation.survival_kids.trackers import (
 3    SurvivalKidsOCRTracker,
 4    SurvivalKidsTracker,
 5)
 6from gameboy_worlds.interface.environment import (
 7    DummyEnvironment,
 8    Environment,
 9    TestEnvironmentMixin,
10    TrainEnvironmentMixin,
11)
12
13
14class SurvivalKidsEnvironment(DummyEnvironment):
15    """A basic Survival Kids environment."""
16
17    REQUIRED_EMULATOR = Emulator
18    REQUIRED_STATE_TRACKER = SurvivalKidsTracker
19
20
21class SurvivalKidsOCREnvironment(SurvivalKidsEnvironment):
22    """A Survival Kids environment that includes OCR region captures."""
23
24    REQUIRED_EMULATOR = Emulator
25    REQUIRED_STATE_TRACKER = SurvivalKidsOCRTracker
26
27    @staticmethod
28    def override_emulator_kwargs(emulator_kwargs: dict) -> dict:
29        Environment.override_state_tracker_class(
30            emulator_kwargs, SurvivalKidsOCREnvironment.REQUIRED_STATE_TRACKER
31        )
32        return emulator_kwargs
33
34
35class SurvivalKidsTestEnvironment(TestEnvironmentMixin, SurvivalKidsOCREnvironment):
36    pass
37
38
39class SurvivalKidsTrainEnvironment(TrainEnvironmentMixin, SurvivalKidsOCREnvironment):
40    pass
class SurvivalKidsEnvironment(typing.Generic[~ObsType, ~ActType]):
15class SurvivalKidsEnvironment(DummyEnvironment):
16    """A basic Survival Kids environment."""
17
18    REQUIRED_EMULATOR = Emulator
19    REQUIRED_STATE_TRACKER = SurvivalKidsTracker

A basic Survival Kids environment.

REQUIRED_EMULATOR = <class 'gameboy_worlds.emulation.emulator.Emulator'>

The highest level emulator that the environment can interface with.

The state tracker that tracks the minimal state information required for the environment to function.

class SurvivalKidsOCREnvironment(typing.Generic[~ObsType, ~ActType]):
22class SurvivalKidsOCREnvironment(SurvivalKidsEnvironment):
23    """A Survival Kids environment that includes OCR region captures."""
24
25    REQUIRED_EMULATOR = Emulator
26    REQUIRED_STATE_TRACKER = SurvivalKidsOCRTracker
27
28    @staticmethod
29    def override_emulator_kwargs(emulator_kwargs: dict) -> dict:
30        Environment.override_state_tracker_class(
31            emulator_kwargs, SurvivalKidsOCREnvironment.REQUIRED_STATE_TRACKER
32        )
33        return emulator_kwargs

A Survival Kids environment that includes OCR region captures.

REQUIRED_EMULATOR = <class 'gameboy_worlds.emulation.emulator.Emulator'>

The highest level emulator that the environment can interface with.

The state tracker that tracks the minimal state information required for the environment to function.

@staticmethod
def override_emulator_kwargs(emulator_kwargs: dict) -> dict:
28    @staticmethod
29    def override_emulator_kwargs(emulator_kwargs: dict) -> dict:
30        Environment.override_state_tracker_class(
31            emulator_kwargs, SurvivalKidsOCREnvironment.REQUIRED_STATE_TRACKER
32        )
33        return emulator_kwargs

Override default emulator keyword arguments for this environment.

Override this method in subclasses to modify the default emulator keyword arguments.

You may want to use override_state_tracker_class or that style to ensure compatibility of state tracker classes.

Arguments:
  • emulator_kwargs (dict): Incoming emulator keyword arguments.
Returns:

dict: The overridden emulator keyword arguments.

class SurvivalKidsTestEnvironment(typing.Generic[~ObsType, ~ActType]):
36class SurvivalKidsTestEnvironment(TestEnvironmentMixin, SurvivalKidsOCREnvironment):
37    pass

Mixin class for testing environments. Ensures the State Tracker used is a TestTrackerMixin and checks these for termination / truncation.

class SurvivalKidsTrainEnvironment(typing.Generic[~ObsType, ~ActType]):
40class SurvivalKidsTrainEnvironment(TrainEnvironmentMixin, SurvivalKidsOCREnvironment):
41    pass

Mixin class for training environments. Records the allowed initial states for training and random shuffles between them when resetting.