Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions test_bot/buggy_engine

This file was deleted.

2 changes: 0 additions & 2 deletions test_bot/buggy_engine.bat

This file was deleted.

11 changes: 8 additions & 3 deletions test_bot/buggy_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

import chess
import time
import typing

if typing.TYPE_CHECKING:
from test_bot.test_games import scholars_mate
else:
from test_games import scholars_mate

assert input() == "uci"

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


send_command("id name Procrastinator")
send_command("id author MZH")
send_command("id author lichess-bot-devs")
send_command("uciok")

delay_performed = False
just_started = True
scholars_mate = ["a2a3", "e7e5", "a3a4", "f8c5", "a4a5", "d8h4", "a5a6", "h4f2"]

board = chess.Board()
while True:
command, *remaining = input().split()
if command == "quit":
Expand Down
3 changes: 0 additions & 3 deletions test_bot/buggy_engine_macos

This file was deleted.

21 changes: 9 additions & 12 deletions test_bot/homemade.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
"""Homemade engine using Stockfish (used in testing)."""
"""Homemade engine playing scholar's mate."""
from homemade import ExampleEngine
import chess
import chess.engine
import sys
from lib.config import Configuration
from lib import model
from lib.lichess_types import OPTIONS_GO_EGTB_TYPE, COMMANDS_TYPE, MOVE
from test_bot.test_games import scholars_mate

# ruff: noqa: ARG002

platform = sys.platform
file_extension = ".exe" if platform == "win32" else ""


class Stockfish(ExampleEngine):
"""A homemade engine that uses Stockfish."""
class ScholarsMate(ExampleEngine):
"""A homemade engine that plays the scholar's mate."""

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

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