Spaces:
Sleeping
Sleeping
Tony commited on
Commit ·
0dcba03
1
Parent(s): 811577e
Updated with last changes
Browse files
config.py
CHANGED
|
@@ -56,5 +56,6 @@ def load_config():
|
|
| 56 |
book_dir = os.path.join(CONFIG["engine"]["dir"], CONFIG["engine"]["polyglot_book"])
|
| 57 |
if not os.path.isfile(book_dir):
|
| 58 |
raise Exception("The polyglot book %s file does not exist." % book_dir)
|
|
|
|
| 59 |
|
| 60 |
return CONFIG
|
|
|
|
| 56 |
book_dir = os.path.join(CONFIG["engine"]["dir"], CONFIG["engine"]["polyglot_book"])
|
| 57 |
if not os.path.isfile(book_dir):
|
| 58 |
raise Exception("The polyglot book %s file does not exist." % book_dir)
|
| 59 |
+
CONFIG["engine"]["polyglot_book"] = book_dir
|
| 60 |
|
| 61 |
return CONFIG
|
main.py
CHANGED
|
@@ -176,15 +176,14 @@ def play_first_book_move(game, engine, board, li, config):
|
|
| 176 |
|
| 177 |
|
| 178 |
def get_book_move(board, engine_cfg):
|
| 179 |
-
book_dir = os.path.join(engine_cfg["dir"], engine_cfg["polyglot_book"])
|
| 180 |
try:
|
| 181 |
-
with chess.polyglot.open_reader(
|
| 182 |
if (engine_cfg["polyglot_random"] == True):
|
| 183 |
book_move = reader.choice(board).move()
|
| 184 |
else:
|
| 185 |
book_move = reader.find(board, engine_cfg["polyglot_min_weight"]).move()
|
| 186 |
return book_move
|
| 187 |
-
except
|
| 188 |
pass
|
| 189 |
|
| 190 |
return None
|
|
|
|
| 176 |
|
| 177 |
|
| 178 |
def get_book_move(board, engine_cfg):
|
|
|
|
| 179 |
try:
|
| 180 |
+
with chess.polyglot.open_reader(engine_cfg["polyglot_book"]) as reader:
|
| 181 |
if (engine_cfg["polyglot_random"] == True):
|
| 182 |
book_move = reader.choice(board).move()
|
| 183 |
else:
|
| 184 |
book_move = reader.find(board, engine_cfg["polyglot_min_weight"]).move()
|
| 185 |
return book_move
|
| 186 |
+
except:
|
| 187 |
pass
|
| 188 |
|
| 189 |
return None
|