gameboy_worlds.interface.deja_vu.environments

 1from typing import Optional, Dict, Any, List, Tuple
 2
 3from gymnasium import spaces
 4
 5from gameboy_worlds.emulation.deja_vu.base_metrics import CoreDejaVuMetrics
 6from gameboy_worlds.utils import load_parameters, log_dict, log_info
 7from gameboy_worlds.emulation.deja_vu.emulators import DejaVuEmulator
 8from gameboy_worlds.emulation.deja_vu.trackers import (
 9    DejaVuOCRTracker,
10    CoreDejaVuTracker,
11    # DejaVuEnterCastleTestTracker,
12)
13from gameboy_worlds.emulation.deja_vu.parsers import AgentState
14from gameboy_worlds.interface.environment import (
15    DummyEnvironment,
16    Environment,
17    TestEnvironmentMixin,
18)
19from gameboy_worlds.interface.controller import Controller
20
21
22class DejaVuEnvironment(DummyEnvironment):
23    """
24    A basic Deja Vu Environment.
25
26    Deja Vu is a detective mystery game focused on investigation and puzzle-solving.
27    The game mechanics include exploration, dialogue interactions, and deduction puzzles.
28    """
29
30    REQUIRED_EMULATOR = DejaVuEmulator
31    REQUIRED_STATE_TRACKER = CoreDejaVuMetrics
32
33
34class DejaVuOCREnvironment(DejaVuEnvironment):
35    """
36    A Deja Vu Environment that includes OCR region captures and agent state.
37
38    Provides screen pixels and agent state information for vision-based agents.
39    Agent state includes: Free Roam, In Dialogue, In Menu, In Puzzle.
40    """
41
42    REQUIRED_STATE_TRACKER = DejaVuOCRTracker
43    REQUIRED_EMULATOR = DejaVuEmulator
44
45    def __init__(self, **kwargs):
46        super().__init__(**kwargs)
47
48    @staticmethod
49    def override_emulator_kwargs(emulator_kwargs: dict) -> dict:
50        required_tracker = DejaVuOCRTracker
51        Environment.override_state_tracker_class(emulator_kwargs, required_tracker)
52        return emulator_kwargs
53
54
55class DejaVuTestEnvironment(TestEnvironmentMixin, DejaVuOCREnvironment):
56    """
57    A test environment for Deja Vu that integrates testing utilities with OCR capabilities.
58    """
59
60    pass
class DejaVuEnvironment(typing.Generic[~ObsType, ~ActType]):
23class DejaVuEnvironment(DummyEnvironment):
24    """
25    A basic Deja Vu Environment.
26
27    Deja Vu is a detective mystery game focused on investigation and puzzle-solving.
28    The game mechanics include exploration, dialogue interactions, and deduction puzzles.
29    """
30
31    REQUIRED_EMULATOR = DejaVuEmulator
32    REQUIRED_STATE_TRACKER = CoreDejaVuMetrics

A basic Deja Vu Environment.

Deja Vu is a detective mystery game focused on investigation and puzzle-solving. The game mechanics include exploration, dialogue interactions, and deduction puzzles.

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 DejaVuOCREnvironment(typing.Generic[~ObsType, ~ActType]):
35class DejaVuOCREnvironment(DejaVuEnvironment):
36    """
37    A Deja Vu Environment that includes OCR region captures and agent state.
38
39    Provides screen pixels and agent state information for vision-based agents.
40    Agent state includes: Free Roam, In Dialogue, In Menu, In Puzzle.
41    """
42
43    REQUIRED_STATE_TRACKER = DejaVuOCRTracker
44    REQUIRED_EMULATOR = DejaVuEmulator
45
46    def __init__(self, **kwargs):
47        super().__init__(**kwargs)
48
49    @staticmethod
50    def override_emulator_kwargs(emulator_kwargs: dict) -> dict:
51        required_tracker = DejaVuOCRTracker
52        Environment.override_state_tracker_class(emulator_kwargs, required_tracker)
53        return emulator_kwargs

A Deja Vu Environment that includes OCR region captures and agent state.

Provides screen pixels and agent state information for vision-based agents. Agent state includes: Free Roam, In Dialogue, In Menu, In Puzzle.

DejaVuOCREnvironment(**kwargs)
46    def __init__(self, **kwargs):
47        super().__init__(**kwargs)

Initializes the DummyEnvironment with the given emulator and controller.

It is safe to overwrite the self.observation_space in the subclass after calling this __init__ method.

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

The highest level emulator that the environment can interface with.

@staticmethod
def override_emulator_kwargs(emulator_kwargs: dict) -> dict:
49    @staticmethod
50    def override_emulator_kwargs(emulator_kwargs: dict) -> dict:
51        required_tracker = DejaVuOCRTracker
52        Environment.override_state_tracker_class(emulator_kwargs, required_tracker)
53        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 DejaVuTestEnvironment(typing.Generic[~ObsType, ~ActType]):
56class DejaVuTestEnvironment(TestEnvironmentMixin, DejaVuOCREnvironment):
57    """
58    A test environment for Deja Vu that integrates testing utilities with OCR capabilities.
59    """
60
61    pass

A test environment for Deja Vu that integrates testing utilities with OCR capabilities.