Spaces:
Sleeping
Sleeping
Commit ·
8c36a5e
1
Parent(s): 8d083d0
corected get_fen() function, where which player has to move next is added
Browse files- __pycache__/main.cpython-311.pyc +0 -0
- main.py +5 -1
- routes/fen_generator.py +5 -2
__pycache__/main.cpython-311.pyc
CHANGED
|
Binary files a/__pycache__/main.cpython-311.pyc and b/__pycache__/main.cpython-311.pyc differ
|
|
|
main.py
CHANGED
|
@@ -88,11 +88,15 @@ async def get_coords(file: UploadFile = File(...)):
|
|
| 88 |
|
| 89 |
|
| 90 |
@app.post("/getFen")
|
| 91 |
-
async def get_fen(file : UploadFile = File(), perspective : str = "w"
|
| 92 |
|
| 93 |
if perspective not in ["w" , "b"]:
|
| 94 |
return JSONResponse(content={"error" : "Perspective should be w (white) or b (black)"}, status_code=500)
|
| 95 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
try:
|
| 97 |
image_content = await file.read()
|
| 98 |
if not image_content:
|
|
|
|
| 88 |
|
| 89 |
|
| 90 |
@app.post("/getFen")
|
| 91 |
+
async def get_fen(file : UploadFile = File(), perspective : str = "w", next_to_move : str = "w"):
|
| 92 |
|
| 93 |
if perspective not in ["w" , "b"]:
|
| 94 |
return JSONResponse(content={"error" : "Perspective should be w (white) or b (black)"}, status_code=500)
|
| 95 |
|
| 96 |
+
if perspective not in ["w" , "b"]:
|
| 97 |
+
return JSONResponse(content={"error" : "Perspective should be w (white) or b (black)"}, status_code=500)
|
| 98 |
+
|
| 99 |
+
|
| 100 |
try:
|
| 101 |
image_content = await file.read()
|
| 102 |
if not image_content:
|
routes/fen_generator.py
CHANGED
|
@@ -41,7 +41,7 @@ def get_grid_coordinate(pixel_x, pixel_y, perspective):
|
|
| 41 |
print(f"Error in get_grid_coordinate: {e}")
|
| 42 |
return None
|
| 43 |
|
| 44 |
-
def gen_fen(result: dict, p: str):
|
| 45 |
try:
|
| 46 |
if not isinstance(result, dict):
|
| 47 |
print("Error: Expected a dictionary for result")
|
|
@@ -107,7 +107,10 @@ def gen_fen(result: dict, p: str):
|
|
| 107 |
fen_row += str(empty_count)
|
| 108 |
fen_rows.append(fen_row) # FIXED: Ensured last row is added
|
| 109 |
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
| 111 |
|
| 112 |
except Exception as e:
|
| 113 |
print(f"Error in gen_fen: {e}")
|
|
|
|
| 41 |
print(f"Error in get_grid_coordinate: {e}")
|
| 42 |
return None
|
| 43 |
|
| 44 |
+
def gen_fen(result: dict, p: str, next_to_move : str):
|
| 45 |
try:
|
| 46 |
if not isinstance(result, dict):
|
| 47 |
print("Error: Expected a dictionary for result")
|
|
|
|
| 107 |
fen_row += str(empty_count)
|
| 108 |
fen_rows.append(fen_row) # FIXED: Ensured last row is added
|
| 109 |
|
| 110 |
+
position_fen = "/".join(fen_rows)
|
| 111 |
+
fen_notation = f"{position_fen}{next_to_move} - - 0 0"
|
| 112 |
+
|
| 113 |
+
return fen_piece
|
| 114 |
|
| 115 |
except Exception as e:
|
| 116 |
print(f"Error in gen_fen: {e}")
|