Spaces:
Sleeping
Sleeping
gbtami commited on
Commit ·
1f7383b
1
Parent(s): 2d59be9
Fix #96 No time control command sent to xboard engine
Browse files- engine_wrapper.py +6 -2
- lichess-bot.py +1 -1
engine_wrapper.py
CHANGED
|
@@ -37,6 +37,9 @@ class EngineWrapper:
|
|
| 37 |
def __init__(self, board, commands, options=None):
|
| 38 |
pass
|
| 39 |
|
|
|
|
|
|
|
|
|
|
| 40 |
def first_search(self, game, board, movetime):
|
| 41 |
pass
|
| 42 |
|
|
@@ -137,16 +140,17 @@ class XBoardEngine(EngineWrapper):
|
|
| 137 |
except EngineStateException:
|
| 138 |
pass
|
| 139 |
|
| 140 |
-
def
|
| 141 |
minutes = game.clock_initial / 1000 / 60
|
| 142 |
seconds = game.clock_initial / 1000 % 60
|
| 143 |
inc = game.clock_increment / 1000
|
|
|
|
| 144 |
|
|
|
|
| 145 |
self.engine.setboard(board)
|
| 146 |
self.engine.level(0, 0, movetime / 1000, 0)
|
| 147 |
bestmove = self.engine.go()
|
| 148 |
|
| 149 |
-
self.engine.level(0, minutes, seconds, inc)
|
| 150 |
return bestmove
|
| 151 |
|
| 152 |
def search(self, board, wtime, btime, winc, binc):
|
|
|
|
| 37 |
def __init__(self, board, commands, options=None):
|
| 38 |
pass
|
| 39 |
|
| 40 |
+
def set_time_control(self, game):
|
| 41 |
+
pass
|
| 42 |
+
|
| 43 |
def first_search(self, game, board, movetime):
|
| 44 |
pass
|
| 45 |
|
|
|
|
| 140 |
except EngineStateException:
|
| 141 |
pass
|
| 142 |
|
| 143 |
+
def set_time_control(self, game):
|
| 144 |
minutes = game.clock_initial / 1000 / 60
|
| 145 |
seconds = game.clock_initial / 1000 % 60
|
| 146 |
inc = game.clock_increment / 1000
|
| 147 |
+
self.engine.level(0, minutes, seconds, inc)
|
| 148 |
|
| 149 |
+
def first_search(self, game, board, movetime):
|
| 150 |
self.engine.setboard(board)
|
| 151 |
self.engine.level(0, 0, movetime / 1000, 0)
|
| 152 |
bestmove = self.engine.go()
|
| 153 |
|
|
|
|
| 154 |
return bestmove
|
| 155 |
|
| 156 |
def search(self, board, wtime, btime, winc, binc):
|
lichess-bot.py
CHANGED
|
@@ -113,6 +113,7 @@ def play_game(li, game_id, control_queue, engine_factory, user_profile, config):
|
|
| 113 |
board = play_first_book_move(game, engine, board, li, engine_cfg)
|
| 114 |
else:
|
| 115 |
board = play_first_move(game, engine, board, li)
|
|
|
|
| 116 |
|
| 117 |
try:
|
| 118 |
for binary_chunk in updates:
|
|
@@ -153,7 +154,6 @@ def play_first_move(game, engine, board, li):
|
|
| 153 |
# need to hardcode first movetime since Lichess has 30 sec limit.
|
| 154 |
best_move = engine.first_search(game, board, 10000)
|
| 155 |
li.make_move(game.id, best_move)
|
| 156 |
-
|
| 157 |
return board
|
| 158 |
|
| 159 |
|
|
|
|
| 113 |
board = play_first_book_move(game, engine, board, li, engine_cfg)
|
| 114 |
else:
|
| 115 |
board = play_first_move(game, engine, board, li)
|
| 116 |
+
engine.set_time_control(game)
|
| 117 |
|
| 118 |
try:
|
| 119 |
for binary_chunk in updates:
|
|
|
|
| 154 |
# need to hardcode first movetime since Lichess has 30 sec limit.
|
| 155 |
best_move = engine.first_search(game, board, 10000)
|
| 156 |
li.make_move(game.id, best_move)
|
|
|
|
| 157 |
return board
|
| 158 |
|
| 159 |
|