anushadudi's picture
Upload folder using huggingface_hub
4d0e1b9 verified
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
"""
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
# Support both in-repo and standalone imports
try:
# In-repo imports (when running from OpenEnv repository)
from core.env_server.types import Action, Observation
except ImportError:
# Standalone imports (when environment is standalone with openenv-core from pip)
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 = []