File size: 1,006 Bytes
c755ba9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# 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 Chess Environment.

The chess environment lets an RL agent play White against a random bot (Black).
"""

from dataclasses import dataclass, field
from typing import List, Optional

from openenv_core.env_server.types import Action, Observation


@dataclass(kw_only=True)
class ChessAction(Action):
    """Action for the Chess environment — a UCI move string (e.g. 'e2e4')."""

    move: str


@dataclass(kw_only=True)
class ChessObservation(Observation):
    """Observation from the Chess environment."""

    board_fen: str
    legal_moves: List[str] = field(default_factory=list)
    white_move: str = ""
    black_move: Optional[str] = None
    material_balance: float = 0.0
    game_status: str = "ongoing"
    captured_pieces: List[str] = field(default_factory=list)