thaihipster commited on
Commit
17cbccb
·
verified ·
1 Parent(s): 173179a

Upload models.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. models.py +42 -0
models.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Data models for the 2048 Game Environment.
3
+
4
+ Actions: 0=up, 1=down, 2=left, 3=right
5
+ """
6
+
7
+ from typing import List, Optional
8
+
9
+ from pydantic import Field
10
+
11
+ # Support both in-repo and standalone imports
12
+ try:
13
+ from openenv.core.env_server.types import Action, Observation, State
14
+ except ImportError:
15
+ from openenv_core.env_server.types import Action, Observation, State
16
+
17
+
18
+ class Game2048Action(Action):
19
+ """Action for the 2048 environment. 0=up, 1=down, 2=left, 3=right."""
20
+
21
+ action: int = Field(ge=0, le=3, description="Direction: 0=up, 1=down, 2=left, 3=right")
22
+
23
+
24
+ class Game2048Observation(Observation):
25
+ """Observation from the 2048 environment."""
26
+
27
+ board: List[List[int]] = Field(default_factory=list, description="4x4 game board")
28
+ score: int = Field(default=0, description="Current total score")
29
+ legal_actions: List[int] = Field(default_factory=list, description="Valid action indices")
30
+ max_tile: int = Field(default=0, description="Highest tile value on the board")
31
+ board_text: str = Field(default="", description="Text rendering of the board")
32
+
33
+
34
+ class Game2048State(State):
35
+ """State for the 2048 environment."""
36
+
37
+ episode_id: Optional[str] = None
38
+ step_count: int = 0
39
+ done: bool = False
40
+ won: bool = False
41
+ score: int = 0
42
+ max_tile: int = 0