gameboy_worlds.interface.harvest_moon.environments
1from typing import Optional, Dict, Any, List, Tuple 2 3from gymnasium import spaces 4 5from gameboy_worlds.emulation.harvest_moon.base_metrics import CoreHarvestMoonMetrics 6from gameboy_worlds.utils import load_parameters, log_dict, log_info 7from gameboy_worlds.emulation.emulator import Emulator 8from gameboy_worlds.emulation.harvest_moon.trackers import ( 9 CoreHarvestMoonTracker, 10 HarvestMoonOCRTracker, 11) 12from gameboy_worlds.interface.environment import ( 13 DummyEnvironment, 14 Environment, 15 TestEnvironmentMixin, 16 TrainEnvironmentMixin, 17) 18from gameboy_worlds.interface.controller import Controller 19 20import gymnasium as gym 21import numpy as np 22 23 24class HarvestMoonEnvironment(DummyEnvironment): 25 """ 26 A basic Harvest Moon Environment. 27 """ 28 29 REQUIRED_EMULATOR = Emulator 30 REQUIRED_STATE_TRACKER = CoreHarvestMoonMetrics 31 32 33class HarvestMoonOCREnvironment(HarvestMoonEnvironment): 34 """ 35 A Harvest Moon Environment that includes OCR region captures and agent state. 36 """ 37 38 REQUIRED_STATE_TRACKER = HarvestMoonOCRTracker 39 REQUIRED_EMULATOR = Emulator 40 41 @staticmethod 42 def override_emulator_kwargs(emulator_kwargs: dict) -> dict: 43 Environment.override_state_tracker_class( 44 emulator_kwargs, HarvestMoonOCREnvironment.REQUIRED_STATE_TRACKER 45 ) 46 return emulator_kwargs 47 48 49class HarvestMoonTestEnvironment(TestEnvironmentMixin, HarvestMoonOCREnvironment): 50 pass 51 52 53class HarvestMoonTrainEnvironment(TrainEnvironmentMixin, HarvestMoonOCREnvironment): 54 pass
25class HarvestMoonEnvironment(DummyEnvironment): 26 """ 27 A basic Harvest Moon Environment. 28 """ 29 30 REQUIRED_EMULATOR = Emulator 31 REQUIRED_STATE_TRACKER = CoreHarvestMoonMetrics
A basic Harvest Moon Environment.
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.
Inherited Members
- gameboy_worlds.interface.environment.DummyEnvironment
- DummyEnvironment
- observation_space
- get_observation
- determine_reward
- determine_terminated
- render_obs
- render_info
- gameboy_worlds.interface.environment.Environment
- override_emulator_kwargs
- override_state_tracker_class
- action_space
- actions
- render_mode
- save_custom_state
- delete_custom_state
- load_custom_state
- get_info
- get_final_info
- reset
- determine_truncated
- before_step
- after_step
- step
- step_high_level_action
- step_str
- string_to_high_level_action
- sim
- sim_str
- sim_high_level_action
- close
- render
- seed
- get_action_strings
- human_step_play
34class HarvestMoonOCREnvironment(HarvestMoonEnvironment): 35 """ 36 A Harvest Moon Environment that includes OCR region captures and agent state. 37 """ 38 39 REQUIRED_STATE_TRACKER = HarvestMoonOCRTracker 40 REQUIRED_EMULATOR = Emulator 41 42 @staticmethod 43 def override_emulator_kwargs(emulator_kwargs: dict) -> dict: 44 Environment.override_state_tracker_class( 45 emulator_kwargs, HarvestMoonOCREnvironment.REQUIRED_STATE_TRACKER 46 ) 47 return emulator_kwargs
A Harvest Moon Environment that includes OCR region captures and agent state.
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.
42 @staticmethod 43 def override_emulator_kwargs(emulator_kwargs: dict) -> dict: 44 Environment.override_state_tracker_class( 45 emulator_kwargs, HarvestMoonOCREnvironment.REQUIRED_STATE_TRACKER 46 ) 47 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.
Inherited Members
- gameboy_worlds.interface.environment.DummyEnvironment
- DummyEnvironment
- observation_space
- get_observation
- determine_reward
- determine_terminated
- render_obs
- render_info
- gameboy_worlds.interface.environment.Environment
- override_state_tracker_class
- action_space
- actions
- render_mode
- save_custom_state
- delete_custom_state
- load_custom_state
- get_info
- get_final_info
- reset
- determine_truncated
- before_step
- after_step
- step
- step_high_level_action
- step_str
- string_to_high_level_action
- sim
- sim_str
- sim_high_level_action
- close
- render
- seed
- get_action_strings
- human_step_play
Mixin class for testing environments. Ensures the State Tracker used is a TestTrackerMixin and checks these for termination / truncation.
Inherited Members
- gameboy_worlds.interface.environment.DummyEnvironment
- DummyEnvironment
- observation_space
- get_observation
- determine_reward
- render_obs
- render_info
- gameboy_worlds.interface.environment.TestEnvironmentMixin
- REQUIRED_STATE_TRACKER
- determine_truncated
- determine_terminated
- gameboy_worlds.interface.environment.Environment
- override_state_tracker_class
- action_space
- actions
- render_mode
- save_custom_state
- delete_custom_state
- load_custom_state
- get_info
- get_final_info
- reset
- before_step
- after_step
- step
- step_high_level_action
- step_str
- string_to_high_level_action
- sim
- sim_str
- sim_high_level_action
- close
- render
- seed
- get_action_strings
- human_step_play
Mixin class for training environments. Records the allowed initial states for training and random shuffles between them when resetting.
Inherited Members
- gameboy_worlds.interface.environment.DummyEnvironment
- DummyEnvironment
- observation_space
- get_observation
- determine_reward
- determine_terminated
- render_obs
- render_info
- gameboy_worlds.interface.environment.Environment
- override_state_tracker_class
- action_space
- actions
- render_mode
- save_custom_state
- delete_custom_state
- load_custom_state
- get_info
- get_final_info
- determine_truncated
- before_step
- after_step
- step
- step_high_level_action
- step_str
- string_to_high_level_action
- sim
- sim_str
- sim_high_level_action
- close
- render
- seed
- get_action_strings
- human_step_play