Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
AttackingOrDefending authored Feb 8, 2024
1 parent d427afe commit 772b4ab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions lib/engine_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import time
import random
import math
import sys
import test_bot.lichess
from collections import Counter
from collections.abc import Callable
Expand Down Expand Up @@ -588,6 +587,9 @@ def method(*args: Any, **kwargs: Any) -> Any:
return method


test_suffix = "-for-lichess-bot-testing-only"


def getHomemadeEngine(name: str) -> type[MinimalEngine]:
"""
Get the homemade engine with name `name`. e.g. If `name` is `RandomMove` then we will return `strategies.RandomMove`.
Expand All @@ -598,8 +600,8 @@ def getHomemadeEngine(name: str) -> type[MinimalEngine]:
from lib import strategies
from test_bot import strategies as test_strategies
engine: type[MinimalEngine]
if "pytest" in sys.modules:
engine = getattr(test_strategies, name)
if name.endswith(test_suffix): # Test only.
engine = getattr(test_strategies, name.removesuffix(test_suffix))
else:
engine = getattr(strategies, name)
return engine
Expand Down
3 changes: 2 additions & 1 deletion test_bot/test_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from lib import config
from lib.timer import Timer, to_seconds, seconds
from typing import Any
from lib.engine_wrapper import test_suffix
if "pytest" not in sys.modules:
sys.exit(f"The script {os.path.basename(__file__)} should only be run by pytest.")
lichess_bot = importlib.import_module("lichess-bot")
Expand Down Expand Up @@ -292,7 +293,7 @@ def test_homemade() -> None:
with open("./config.yml.default") as file:
CONFIG = yaml.safe_load(file)
CONFIG["token"] = ""
CONFIG["engine"]["name"] = "Stockfish"
CONFIG["engine"]["name"] = f"Stockfish{test_suffix}"
CONFIG["engine"]["protocol"] = "homemade"
CONFIG["pgn_directory"] = "TEMP/homemade_game_record"
win = run_bot(CONFIG, logging_level)
Expand Down

0 comments on commit 772b4ab

Please sign in to comment.