luccabb commited on
Commit
e5572a6
·
verified ·
1 Parent(s): 23f0779

Upload folder using huggingface_hub

Browse files
client.py CHANGED
@@ -1,7 +1,7 @@
1
  """Client for the Chess OpenEnv environment."""
2
 
3
  from dataclasses import dataclass
4
- from typing import Any, Dict, List, Optional
5
 
6
  import httpx
7
 
@@ -65,7 +65,7 @@ class ChessEnvClient:
65
  Returns:
66
  Initial observation of the board state
67
  """
68
- payload = {}
69
  if seed is not None:
70
  payload["seed"] = seed
71
  if episode_id is not None:
 
1
  """Client for the Chess OpenEnv environment."""
2
 
3
  from dataclasses import dataclass
4
+ from typing import Any, Dict, Optional
5
 
6
  import httpx
7
 
 
65
  Returns:
66
  Initial observation of the board state
67
  """
68
+ payload: Dict[str, Any] = {}
69
  if seed is not None:
70
  payload["seed"] = seed
71
  if episode_id is not None:
examples/basic_usage.py CHANGED
@@ -89,7 +89,7 @@ def demonstrate_illegal_move():
89
  illegal_action = ChessAction(move="e2e5") # Can't move pawn 3 squares
90
  obs, reward, done = env.step(illegal_action)
91
 
92
- print(f"Attempted illegal move: e2e5")
93
  print(f"Reward: {reward}") # Should be negative
94
  print(f"Error: {obs.metadata.get('error', 'None')}")
95
  print(f"Done: {done}") # Game continues
 
89
  illegal_action = ChessAction(move="e2e5") # Can't move pawn 3 squares
90
  obs, reward, done = env.step(illegal_action)
91
 
92
+ print("Attempted illegal move: e2e5")
93
  print(f"Reward: {reward}") # Should be negative
94
  print(f"Error: {obs.metadata.get('error', 'None')}")
95
  print(f"Done: {done}") # Game continues
examples/openenv_training.py CHANGED
@@ -17,7 +17,7 @@ Usage:
17
  """
18
 
19
  import random
20
- from moonfish.rl import ChessEnvClient, ChessAction, make_env
21
 
22
 
23
  def random_policy(legal_moves: list[str]) -> str:
 
17
  """
18
 
19
  import random
20
+ from moonfish.rl import ChessAction, make_env
21
 
22
 
23
  def random_policy(legal_moves: list[str]) -> str:
models.py CHANGED
@@ -1,7 +1,7 @@
1
  """Data models for the Chess OpenEnv environment."""
2
 
3
  from dataclasses import dataclass, field
4
- from typing import Any, Dict, List, Optional, Union
5
 
6
 
7
  @dataclass
 
1
  """Data models for the Chess OpenEnv environment."""
2
 
3
  from dataclasses import dataclass, field
4
+ from typing import Any, Dict, List, Optional
5
 
6
 
7
  @dataclass
server/app.py CHANGED
@@ -1,9 +1,7 @@
1
  """FastAPI server for the Chess OpenEnv environment."""
2
 
3
- import os
4
  from pathlib import Path
5
  from typing import Any, Dict, Optional
6
- from dataclasses import asdict
7
 
8
  import chess
9
  from fastapi import FastAPI, HTTPException
@@ -12,7 +10,7 @@ from fastapi.responses import FileResponse
12
  from pydantic import BaseModel
13
 
14
  from moonfish.lib import search_move
15
- from ..models import ChessAction, RewardConfig
16
  from .chess_environment import ChessEnvironment
17
 
18
 
 
1
  """FastAPI server for the Chess OpenEnv environment."""
2
 
 
3
  from pathlib import Path
4
  from typing import Any, Dict, Optional
 
5
 
6
  import chess
7
  from fastapi import FastAPI, HTTPException
 
10
  from pydantic import BaseModel
11
 
12
  from moonfish.lib import search_move
13
+ from ..models import ChessAction
14
  from .chess_environment import ChessEnvironment
15
 
16
 
server/chess_environment.py CHANGED
@@ -2,7 +2,7 @@
2
 
3
  import random
4
  import uuid
5
- from typing import Any, Dict, List, Optional, Tuple
6
 
7
  import chess
8
 
 
2
 
3
  import random
4
  import uuid
5
+ from typing import Any, Dict, Optional, Tuple
6
 
7
  import chess
8