Spaces:
Running
Running
Update agent.py
Browse files
agent.py
CHANGED
@@ -324,8 +324,6 @@ class MagAgent:
|
|
324 |
|
325 |
|
326 |
class ChessEngineTool(Tool):
|
327 |
-
import chess
|
328 |
-
import chess.engine
|
329 |
name = "stockfish_analysis"
|
330 |
description = "Analyzes chess position using Stockfish and returns best move"
|
331 |
inputs = {
|
@@ -343,9 +341,11 @@ class MagAgent:
|
|
343 |
|
344 |
def forward(self, fen: str) -> str:
|
345 |
try:
|
|
|
|
|
346 |
board = chess.Board(fen)
|
347 |
engine = chess.engine.SimpleEngine.popen_uci("stockfish")
|
348 |
-
result = engine.play(board, chess.engine.Limit(time=
|
349 |
engine.quit()
|
350 |
return board.san(result.move)
|
351 |
except Exception as e:
|
|
|
324 |
|
325 |
|
326 |
class ChessEngineTool(Tool):
|
|
|
|
|
327 |
name = "stockfish_analysis"
|
328 |
description = "Analyzes chess position using Stockfish and returns best move"
|
329 |
inputs = {
|
|
|
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:
|