Spaces:
Sleeping
Sleeping
Update agent.py
Browse files
agent.py
CHANGED
|
@@ -338,20 +338,19 @@ class MagAgent:
|
|
| 338 |
}
|
| 339 |
}
|
| 340 |
output_type = "string"
|
| 341 |
-
|
| 342 |
-
def forward(self, fen: str) -> str:
|
|
|
|
| 343 |
try:
|
| 344 |
import chess
|
| 345 |
import chess.engine
|
| 346 |
board = chess.Board(fen)
|
| 347 |
engine = chess.engine.SimpleEngine.popen_uci("stockfish")
|
| 348 |
-
result = engine.play(board, chess.engine.Limit(time=time_limit))
|
| 349 |
engine.quit()
|
| 350 |
return board.san(result.move)
|
| 351 |
except Exception as e:
|
| 352 |
-
return f"Engine error: {str(e)}"
|
| 353 |
-
|
| 354 |
-
|
| 355 |
|
| 356 |
class PythonCodeReaderTool(Tool):
|
| 357 |
name = "read_python_code"
|
|
|
|
| 338 |
}
|
| 339 |
}
|
| 340 |
output_type = "string"
|
| 341 |
+
|
| 342 |
+
def forward(self, fen: str, time_limit: float = 0.1) -> str: # Add time_limit parameter
|
| 343 |
+
"""Analyzes chess position using Stockfish engine"""
|
| 344 |
try:
|
| 345 |
import chess
|
| 346 |
import chess.engine
|
| 347 |
board = chess.Board(fen)
|
| 348 |
engine = chess.engine.SimpleEngine.popen_uci("stockfish")
|
| 349 |
+
result = engine.play(board, chess.engine.Limit(time=time_limit)) # Use parameter
|
| 350 |
engine.quit()
|
| 351 |
return board.san(result.move)
|
| 352 |
except Exception as e:
|
| 353 |
+
return f"Engine error: {str(e)}"
|
|
|
|
|
|
|
| 354 |
|
| 355 |
class PythonCodeReaderTool(Tool):
|
| 356 |
name = "read_python_code"
|