configured lichess bot to use our bayesian mcts with Stockfish strategy
This commit is contained in:
@@ -13,7 +13,8 @@ from typing import Any
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
import chesspp
|
import chesspp
|
||||||
from chesspp.engine import ClassicMctsEngine, BayesMctsEngine
|
from chesspp.engine import ClassicMctsEngine, Engine
|
||||||
|
from chesspp.engine_factory import EngineFactory, EngineEnum, StrategyEnum
|
||||||
|
|
||||||
# Use this logger variable to print messages to the console or log files.
|
# Use this logger variable to print messages to the console or log files.
|
||||||
# logger.info("message") will always print "message" to the console or log file.
|
# logger.info("message") will always print "message" to the console or log file.
|
||||||
@@ -128,11 +129,27 @@ class MctsEngine(MinimalEngine):
|
|||||||
|
|
||||||
|
|
||||||
class MyBayesMctsEngine(MinimalEngine):
|
class MyBayesMctsEngine(MinimalEngine):
|
||||||
|
def __init__(self, commands: COMMANDS_TYPE, options: OPTIONS_TYPE, stderr: Optional[int],
|
||||||
|
draw_or_resign: Configuration, name: Optional[str] = None, **popen_args: str) -> None:
|
||||||
|
"""
|
||||||
|
Initialize the values of the engine that all homemade engines inherit.
|
||||||
|
|
||||||
|
:param options: The options to send to the engine.
|
||||||
|
:param draw_or_resign: Options on whether the bot should resign or offer draws.
|
||||||
|
"""
|
||||||
|
super().__init__(commands, options, stderr, draw_or_resign, name, **popen_args)
|
||||||
|
self._engine = None
|
||||||
|
|
||||||
|
def get_engine(self, color: chess.Color) -> chess.engine:
|
||||||
|
if self._engine is None:
|
||||||
|
self._engine = EngineFactory.create_engine(EngineEnum.BayesianMcts, StrategyEnum.Stockfish, color,
|
||||||
|
"/home/luke/projects/pp-project/chess-engine-pp/stockfish/stockfish-ubuntu-x86-64-avx2",
|
||||||
|
"", 1500, 4)
|
||||||
|
|
||||||
|
return self._engine
|
||||||
|
|
||||||
def search(self, board: chess.Board, time_limit: chess.engine.Limit, ponder: bool, draw_offered: bool,
|
def search(self, board: chess.Board, time_limit: chess.engine.Limit, ponder: bool, draw_offered: bool,
|
||||||
root_moves: MOVE) -> chess.engine.PlayResult:
|
root_moves: MOVE) -> chess.engine.PlayResult:
|
||||||
my_engine = BayesMctsEngine(board.turn)
|
my_engine = self.get_engine(board.turn)
|
||||||
r = my_engine.play(board.copy(), chesspp.engine.Limit(0.5))
|
r = my_engine.play(board.copy(), chesspp.engine.Limit(2))
|
||||||
print("Color:", board.turn)
|
|
||||||
print("engine play result: ", r)
|
|
||||||
print("Engine name", my_engine)
|
|
||||||
return r
|
return r
|
||||||
|
|||||||
20
pyproject.toml
Normal file
20
pyproject.toml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
[build-system]
|
||||||
|
requires = ["setuptools >= 61.0"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "chess-pp"
|
||||||
|
version = "0.1"
|
||||||
|
dependencies = [
|
||||||
|
"chess==1.10.0",
|
||||||
|
"numpy==1.26.3",
|
||||||
|
"stockfish==3.28.0",
|
||||||
|
"torch==2.1.2",
|
||||||
|
"pytest==8.0.0",
|
||||||
|
"aiohttp==3.9.2",
|
||||||
|
"scipy==1.12.0"
|
||||||
|
]
|
||||||
|
requires-python = ">= 3.10"
|
||||||
|
|
||||||
|
[tool.setuptools]
|
||||||
|
py-modules = ["chesspp"]
|
||||||
Reference in New Issue
Block a user