File size: 1,170 Bytes
7d5289a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# 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 Gymnasium-based environments.

This module defines generic Action, Observation, and State representations
used by the Gym environment integration.
"""

from __future__ import annotations

from dataclasses import dataclass
from typing import Any, Optional

from core.env_server import Action, Observation, State


@dataclass
class GymAction(Action):
    """Generic action wrapper for Gymnasium environments."""

    action: Any


@dataclass
class GymObservation(Observation):
    """Observation returned by a Gymnasium environment."""

    state: Any
    legal_actions: Optional[Any] = None
    episode_length: int = 0
    total_reward: float = 0.0


@dataclass
class GymState(State):
    """Server-side state snapshot for Gymnasium environments."""

    env_id: str = "Unknown"
    render_mode: Optional[str] = None
    max_steps: Optional[int] = None
    seed: Optional[int] = None
    episode_length: int = 0
    total_reward: float = 0.0