Skip to content

Commit 206e858

Browse files
authored
Make engine testing local (#1160)
* Make UCI and XBoard tests local No need to download any chess engines. Mypy does not see test_games.py * Delete unused import * Delete unneeded external files and opponent arg * Add fix for imports to satisfy mypy * Use sys.executable for portability * Break up over-complicated line * Delete trivial testing engine
1 parent b98476d commit 206e858

9 files changed

Lines changed: 163 additions & 247 deletions

File tree

test_bot/buggy_engine

Lines changed: 0 additions & 3 deletions
This file was deleted.

test_bot/buggy_engine.bat

Lines changed: 0 additions & 2 deletions
This file was deleted.

test_bot/buggy_engine.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
import chess
44
import time
5+
import typing
6+
7+
if typing.TYPE_CHECKING:
8+
from test_bot.test_games import scholars_mate
9+
else:
10+
from test_games import scholars_mate
511

612
assert input() == "uci"
713

@@ -12,13 +18,12 @@ def send_command(command: str) -> None:
1218

1319

1420
send_command("id name Procrastinator")
15-
send_command("id author MZH")
21+
send_command("id author lichess-bot-devs")
1622
send_command("uciok")
1723

1824
delay_performed = False
1925
just_started = True
20-
scholars_mate = ["a2a3", "e7e5", "a3a4", "f8c5", "a4a5", "d8h4", "a5a6", "h4f2"]
21-
26+
board = chess.Board()
2227
while True:
2328
command, *remaining = input().split()
2429
if command == "quit":

test_bot/buggy_engine_macos

Lines changed: 0 additions & 3 deletions
This file was deleted.

test_bot/homemade.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,25 @@
1-
"""Homemade engine using Stockfish (used in testing)."""
1+
"""Homemade engine playing scholar's mate."""
22
from homemade import ExampleEngine
33
import chess
44
import chess.engine
5-
import sys
65
from lib.config import Configuration
76
from lib import model
87
from lib.lichess_types import OPTIONS_GO_EGTB_TYPE, COMMANDS_TYPE, MOVE
8+
from test_bot.test_games import scholars_mate
99

1010
# ruff: noqa: ARG002
1111

12-
platform = sys.platform
13-
file_extension = ".exe" if platform == "win32" else ""
14-
15-
16-
class Stockfish(ExampleEngine):
17-
"""A homemade engine that uses Stockfish."""
12+
class ScholarsMate(ExampleEngine):
13+
"""A homemade engine that plays the scholar's mate."""
1814

1915
def __init__(self, commands: COMMANDS_TYPE, options: OPTIONS_GO_EGTB_TYPE, stderr: int | None,
2016
draw_or_resign: Configuration, game: model.Game | None, **popen_args: str) -> None:
21-
"""Start Stockfish."""
17+
"""Set up engine."""
2218
super().__init__(commands, options, stderr, draw_or_resign, game, **popen_args)
23-
self.engine = chess.engine.SimpleEngine.popen_uci(f"./TEMP/sf{file_extension}")
2419

2520
def search(self, board: chess.Board, time_limit: chess.engine.Limit, ponder: bool, draw_offered: bool,
2621
root_moves: MOVE) -> chess.engine.PlayResult:
27-
"""Get a move using Stockfish."""
28-
return self.engine.play(board, time_limit)
22+
"""Get the next scholar's mate move."""
23+
move_number = len(board.move_stack)
24+
move = board.parse_uci(scholars_mate[move_number])
25+
return chess.engine.PlayResult(move, None)

0 commit comments

Comments
 (0)