Spaces:
Sleeping
Sleeping
TheYoBots commited on
Commit ·
6155768
1
Parent(s): 2849f1e
Send go commands properly
Browse files- engine_wrapper.py +24 -14
engine_wrapper.py
CHANGED
|
@@ -19,7 +19,7 @@ def create_engine(config, board):
|
|
| 19 |
|
| 20 |
silence_stderr = cfg.get("silence_stderr", False)
|
| 21 |
|
| 22 |
-
return USIEngine(board, commands, cfg.get("usi_options", {})
|
| 23 |
|
| 24 |
|
| 25 |
class EngineWrapper:
|
|
@@ -64,10 +64,9 @@ class EngineWrapper:
|
|
| 64 |
|
| 65 |
class USIEngine(EngineWrapper):
|
| 66 |
|
| 67 |
-
|
| 68 |
-
commands = commands[0] if len(commands) == 1 else commands
|
| 69 |
-
self.go_commands =
|
| 70 |
-
print("GO, OPTIONS:", options)
|
| 71 |
|
| 72 |
self.engine = engine_ctrl.Engine(commands)
|
| 73 |
self.engine.usi()
|
|
@@ -82,15 +81,26 @@ class USIEngine(EngineWrapper):
|
|
| 82 |
|
| 83 |
def search_with_ponder(self, board, wtime, btime, winc, binc, ponder=False):
|
| 84 |
moves = [m.usi() for m in list(board.move_stack)]
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
return (best_move, ponder_move)
|
| 95 |
|
| 96 |
def search(self, board, wtime, btime, winc, binc):
|
|
|
|
| 19 |
|
| 20 |
silence_stderr = cfg.get("silence_stderr", False)
|
| 21 |
|
| 22 |
+
return USIEngine(board, commands, cfg.get("usi_options", {}), cfg.get("go_commands", {}), silence_stderr)
|
| 23 |
|
| 24 |
|
| 25 |
class EngineWrapper:
|
|
|
|
| 64 |
|
| 65 |
class USIEngine(EngineWrapper):
|
| 66 |
|
| 67 |
+
def __init__(self, board, commands, options, go_commands={}, silence_stderr=False):
|
| 68 |
+
commands = commands[0] if len(commands) == 1 else commands
|
| 69 |
+
self.go_commands = go_commands
|
|
|
|
| 70 |
|
| 71 |
self.engine = engine_ctrl.Engine(commands)
|
| 72 |
self.engine.usi()
|
|
|
|
| 81 |
|
| 82 |
def search_with_ponder(self, board, wtime, btime, winc, binc, ponder=False):
|
| 83 |
moves = [m.usi() for m in list(board.move_stack)]
|
| 84 |
+
cmds = self.go_commands
|
| 85 |
+
if len(cmds) > 0:
|
| 86 |
+
best_move, ponder_move = self.engine.go(
|
| 87 |
+
board.sfen(),
|
| 88 |
+
moves,
|
| 89 |
+
nodes=cmds.get("nodes"),
|
| 90 |
+
depth=cmds.get("depth"),
|
| 91 |
+
movetime=cmds.get("movetime"),
|
| 92 |
+
#ponder=ponder
|
| 93 |
+
)
|
| 94 |
+
else:
|
| 95 |
+
best_move, ponder_move = self.engine.go(
|
| 96 |
+
board.sfen(),
|
| 97 |
+
moves,
|
| 98 |
+
wtime=wtime,
|
| 99 |
+
btime=btime,
|
| 100 |
+
winc=winc,
|
| 101 |
+
binc=binc,
|
| 102 |
+
#ponder=ponder
|
| 103 |
+
)
|
| 104 |
return (best_move, ponder_move)
|
| 105 |
|
| 106 |
def search(self, board, wtime, btime, winc, binc):
|