Spaces:
Sleeping
Sleeping
Merge pull request #162 from careless25/ponder
Browse filesFix 'logger' not defined errors and engine_opts
- config.yml.default +2 -7
- conversation.py +2 -0
- engine_wrapper.py +4 -19
- lichess-bot.py +5 -4
config.yml.default
CHANGED
|
@@ -19,6 +19,8 @@ engine: # engine settings
|
|
| 19 |
max_depth: 8 # half move max depth
|
| 20 |
min_weight: 1 # selects move with highest weight but not below this value
|
| 21 |
selection: "weighted_random" # move slection is one of "weighted_random", "uniform_random" or "best_move" (but not below the min_weight in 2. and 3. case)
|
|
|
|
|
|
|
| 22 |
uci_options: # arbitrary UCI options passed to the engine
|
| 23 |
Move Overhead: 100 # increase if your bot flags games too often
|
| 24 |
Threads: 2 # max CPU threads the engine can use
|
|
@@ -35,13 +37,6 @@ engine: # engine settings
|
|
| 35 |
# nalimov: "Nalimov Path"
|
| 36 |
# scorpio: "Scorpio Path"
|
| 37 |
# syzygy: "Syzygy Path"
|
| 38 |
-
# lczero: # lczero specific settings
|
| 39 |
-
# weights: "engines/latest.txt" # weights file path
|
| 40 |
-
# threads: 1 # max CPU threads the engine can use
|
| 41 |
-
# gpu: 0 # which GPU to use
|
| 42 |
-
# tempdecay: 10 # After search is complete, the tempdecay can pick slightly weaker moves to offer variety. 10 is good tradeoff
|
| 43 |
-
# noise: true # Randomness in the search algorithm. This makes sure that even unfavored lines are given a "lucky" shot
|
| 44 |
-
# log: "./engines/log.txt" # save log of lczero debug output
|
| 45 |
silence_stderr: false # some engines (yes you, leela) are very noisy
|
| 46 |
|
| 47 |
abort_time: 20 # time to abort a game in seconds when there is no activity
|
|
|
|
| 19 |
max_depth: 8 # half move max depth
|
| 20 |
min_weight: 1 # selects move with highest weight but not below this value
|
| 21 |
selection: "weighted_random" # move slection is one of "weighted_random", "uniform_random" or "best_move" (but not below the min_weight in 2. and 3. case)
|
| 22 |
+
# engine_options: # any custom command line params to pass to the engine
|
| 23 |
+
# cpuct: 3.1
|
| 24 |
uci_options: # arbitrary UCI options passed to the engine
|
| 25 |
Move Overhead: 100 # increase if your bot flags games too often
|
| 26 |
Threads: 2 # max CPU threads the engine can use
|
|
|
|
| 37 |
# nalimov: "Nalimov Path"
|
| 38 |
# scorpio: "Scorpio Path"
|
| 39 |
# syzygy: "Syzygy Path"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
silence_stderr: false # some engines (yes you, leela) are very noisy
|
| 41 |
|
| 42 |
abort_time: 20 # time to abort a game in seconds when there is no activity
|
conversation.py
CHANGED
|
@@ -16,6 +16,8 @@ class Conversation():
|
|
| 16 |
pass
|
| 17 |
|
| 18 |
def command(self, line, game, cmd):
|
|
|
|
|
|
|
| 19 |
if cmd == "wait" and game.is_abortable():
|
| 20 |
game.abort_in(60)
|
| 21 |
self.send_reply(line, "Waiting 60 seconds...")
|
|
|
|
| 16 |
pass
|
| 17 |
|
| 18 |
def command(self, line, game, cmd):
|
| 19 |
+
if cmd == "commands" or cmd == "help":
|
| 20 |
+
self.send_reply(line, "Supported commands: !name, !howto, and !eval")
|
| 21 |
if cmd == "wait" and game.is_abortable():
|
| 22 |
game.abort_in(60)
|
| 23 |
self.send_reply(line, "Waiting 60 seconds...")
|
engine_wrapper.py
CHANGED
|
@@ -10,26 +10,11 @@ def create_engine(config, board):
|
|
| 10 |
cfg = config["engine"]
|
| 11 |
engine_path = os.path.join(cfg["dir"], cfg["name"])
|
| 12 |
engine_type = cfg.get("protocol")
|
| 13 |
-
|
| 14 |
commands = [engine_path]
|
| 15 |
-
if
|
| 16 |
-
|
| 17 |
-
commands.append("-
|
| 18 |
-
commands.append(lczero_options["weights"])
|
| 19 |
-
if "threads" in lczero_options:
|
| 20 |
-
commands.append("-t")
|
| 21 |
-
commands.append(str(lczero_options["threads"]))
|
| 22 |
-
if "gpu" in lczero_options:
|
| 23 |
-
commands.append("--gpu")
|
| 24 |
-
commands.append(str(lczero_options["gpu"]))
|
| 25 |
-
if "tempdecay" in lczero_options:
|
| 26 |
-
commands.append("--tempdecay")
|
| 27 |
-
commands.append(str(lczero_options["tempdecay"]))
|
| 28 |
-
if lczero_options.get("noise"):
|
| 29 |
-
commands.append("--noise")
|
| 30 |
-
if "log" in lczero_options:
|
| 31 |
-
commands.append("--logfile")
|
| 32 |
-
commands.append(lczero_options["log"])
|
| 33 |
|
| 34 |
silence_stderr = cfg.get("silence_stderr", False)
|
| 35 |
|
|
|
|
| 10 |
cfg = config["engine"]
|
| 11 |
engine_path = os.path.join(cfg["dir"], cfg["name"])
|
| 12 |
engine_type = cfg.get("protocol")
|
| 13 |
+
engine_options = cfg.get("engine_options")
|
| 14 |
commands = [engine_path]
|
| 15 |
+
if engine_options:
|
| 16 |
+
for k, v in engine_options.items():
|
| 17 |
+
commands.append("--{}={}".format(k, v))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
silence_stderr = cfg.get("silence_stderr", False)
|
| 20 |
|
lichess-bot.py
CHANGED
|
@@ -21,13 +21,15 @@ from requests.exceptions import ChunkedEncodingError, ConnectionError, HTTPError
|
|
| 21 |
from urllib3.exceptions import ProtocolError
|
| 22 |
from ColorLogger import enable_color_logging
|
| 23 |
|
|
|
|
|
|
|
| 24 |
try:
|
| 25 |
from http.client import RemoteDisconnected
|
| 26 |
# New in version 3.5: Previously, BadStatusLine('') was raised.
|
| 27 |
except ImportError:
|
| 28 |
from http.client import BadStatusLine as RemoteDisconnected
|
| 29 |
|
| 30 |
-
__version__ = "1.1.
|
| 31 |
|
| 32 |
terminated = False
|
| 33 |
|
|
@@ -286,10 +288,9 @@ if __name__ == "__main__":
|
|
| 286 |
parser.add_argument('-l', '--logfile', help="Log file to append logs to.", default=None)
|
| 287 |
args = parser.parse_args()
|
| 288 |
|
| 289 |
-
logging.basicConfig(level=logging.DEBUG if args.v else logging.INFO, filename=args.logfile,
|
| 290 |
-
|
| 291 |
logger.info(intro())
|
| 292 |
-
|
| 293 |
CONFIG = load_config(args.config or "./config.yml")
|
| 294 |
li = lichess.Lichess(CONFIG["token"], CONFIG["url"], __version__)
|
| 295 |
|
|
|
|
| 21 |
from urllib3.exceptions import ProtocolError
|
| 22 |
from ColorLogger import enable_color_logging
|
| 23 |
|
| 24 |
+
logger = logging.getLogger(__name__)
|
| 25 |
+
|
| 26 |
try:
|
| 27 |
from http.client import RemoteDisconnected
|
| 28 |
# New in version 3.5: Previously, BadStatusLine('') was raised.
|
| 29 |
except ImportError:
|
| 30 |
from http.client import BadStatusLine as RemoteDisconnected
|
| 31 |
|
| 32 |
+
__version__ = "1.1.2"
|
| 33 |
|
| 34 |
terminated = False
|
| 35 |
|
|
|
|
| 288 |
parser.add_argument('-l', '--logfile', help="Log file to append logs to.", default=None)
|
| 289 |
args = parser.parse_args()
|
| 290 |
|
| 291 |
+
logging.basicConfig(level=logging.DEBUG if args.v else logging.INFO, filename=args.logfile,
|
| 292 |
+
format="%(asctime)-15s: %(message)s")
|
| 293 |
logger.info(intro())
|
|
|
|
| 294 |
CONFIG = load_config(args.config or "./config.yml")
|
| 295 |
li = lichess.Lichess(CONFIG["token"], CONFIG["url"], __version__)
|
| 296 |
|