|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
""" |
|
|
Data models for the Number Guessing Game Environment. |
|
|
|
|
|
In this environment, the agent tries to guess a secret number between 1 and 100. |
|
|
The environment provides hints (higher/lower) after each guess. |
|
|
""" |
|
|
|
|
|
from dataclasses import dataclass |
|
|
|
|
|
|
|
|
try: |
|
|
|
|
|
from core.env_server.types import Action, Observation |
|
|
except ImportError: |
|
|
|
|
|
from openenv_core.env_server.types import Action, Observation |
|
|
|
|
|
|
|
|
@dataclass(kw_only=True) |
|
|
class GuessAction(Action): |
|
|
""" |
|
|
Action for the Number Guessing Game - a number guess. |
|
|
|
|
|
Attributes: |
|
|
guess: The number the agent is guessing (1-100) |
|
|
""" |
|
|
guess: int |
|
|
|
|
|
|
|
|
@dataclass(kw_only=True) |
|
|
class GuessObservation(Observation): |
|
|
""" |
|
|
Observation from the Number Guessing Game. |
|
|
|
|
|
Attributes: |
|
|
hint: Feedback from the environment ("correct", "higher", "lower", or "invalid") |
|
|
attempts_remaining: Number of attempts left before game over |
|
|
guess_history: List of previous guesses made |
|
|
""" |
|
|
hint: str |
|
|
attempts_remaining: int = 10 |
|
|
guess_history: list[int] = None |
|
|
|
|
|
def __post_init__(self): |
|
|
"""Initialize guess_history if not provided.""" |
|
|
if self.guess_history is None: |
|
|
self.guess_history = [] |
|
|
|