Skip to content

Make CMHMEngine2 UCI Compliant #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
30 tasks
Phillyclause89 opened this issue May 15, 2025 · 0 comments
Open
30 tasks

Make CMHMEngine2 UCI Compliant #53

Phillyclause89 opened this issue May 15, 2025 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@Phillyclause89
Copy link
Owner

Title: Make CMHMEngine2 UCI Compliant

Background:
CMHMEngine2 currently speaks only our internal command format. To allow integration with standard chess GUIs (Arena, SCID, Cute Chess, etc.) and external tools (e.g. e-mail-based tournaments, remote engine tournaments), we need to implement the Universal Chess Interface (UCI) protocol.

Goals:

  • Enable seamless communication between CMHMEngine2 and any UCI-aware front-end.
  • Maintain robust testing and documentation so future contributors can extend or debug UCI handling.

Tasks

1. Specification & Research

  • Review the official UCI protocol specification (e.g. backscattering.de/chess/uci/uci.txt).
  • Identify all mandatory commands (uci, isready, ucinewgame, position, go, stop, quit).
  • List optional but common commands (e.g. debug, setoption) and decide which to support initially.

2. Core Command Implementation

  • Implement uci handshake:

    • Engine prints ID and “uciok” when seeing uci.
    • Handle isready → print “readyok”.
    • Respond to ucinewgame by resetting internal state.
  • Parse position command:

    • Support position startpos [moves …].
    • Support position fen <FEN> [moves …].
  • Parse and execute go subcommands:

    • go movetime <ms>, go depth <d>, go nodes <n>, etc.
    • Send best move via bestmove <move> [ ponder <move>].
  • Handle stop (early termination) and print current best move.

  • Handle quit clean shutdown.

3. Optional / Extended Features

  • Support setoption name <name> value <value> for engine tuning.
  • Support ucinewgame full reinitialization (clearing transposition tables, Q-table, etc.).
  • Add debug on|off for verbose logging.

4. Testing & Validation

  • Write unit tests for each parser function (one per command).

  • Simulate UCI session in tests (feed a sequence of commands, assert outputs).

  • Manual integration tests with at least two GUIs:

    • Arena
    • SCID or Cute Chess

5. Documentation

  • Update README with a “UCI Usage” section: example CLI session.
  • Document all supported setoption parameters.

Acceptance Criteria

  • CMHMEngine2 prints the correct UCI handshake and acknowledges readiness.
  • All mandatory UCI commands are parsed and executed correctly.
  • Engine returns valid bestmove under each go mode tested.
  • CI pipeline runs parser/unit tests and they all pass.
  • README clearly shows how to launch CMHMEngine2 from a UCI-compatible GUI.

Additional Resources for UCI in Python Engines

To help you dive deeper into the Universal Chess Interface and see practical Python implementations, here’s a curated list of specifications, library documentation, tutorials, and community Q&A threads:

Official UCI Specifications

  • UCI Protocol Specification (official text file by Rudolf Huber & Stefan Meyer-Kahlen): the definitive description of every mandatory and optional command in UCI ([Gist]1)
  • UCI History & Design on Wikipedia: background on protocol origins, design goals, and adoption timeline ([Wikipedia]2)

Python Libraries & Example Engines

  • python-chess UCI/XBoard module: comprehensive docs for using and embedding UCI engines in Python (including chess.uci.Engine, uci(), isready(), etc.) ([python-chess.readthedocs.io]3)
  • Disservin/python-chess-engine on GitHub: a minimal UCI-compatible engine implemented with python-chess, complete with alpha-beta search and move ordering ([GitHub]4)
  • Stockfish Discussions: UCI code examples: real-world examples of sending commands to and reading responses from Stockfish via stdin/stdout ([GitHub]5)

Tutorials & Articles

  • “How do I implement UCI in my Python chess engine?” (Chess StackExchange): step-by-step community answers on parsing and responding to UCI commands ([Chess Stack Exchange]6)
  • Writing a UCI Client in Java by André Inc: while in Java, this guide breaks down protocol flows in a language-agnostic way that’s directly applicable to Python ([andreinc]7)

Community Q&A & Troubleshooting

  • “How can I build a chess UCI computer in Python?” (Stack Overflow): detailed answers on wiring up Python code to the UCI protocol for Lichess and GUIs ([Stack Overflow]8)
  • Reddit r/chess: modifying Python engine for UCI: peer discussion on the key implementation pitfalls and deployment considerations ([Reddit]9)
  • Chessprogramming.org: UCI article: in-depth protocol overview plus historical notes and links to variant protocols (USI, UCCI) ([chessprogramming.org]10)
@Phillyclause89 Phillyclause89 added this to the Future milestone May 15, 2025
@Phillyclause89 Phillyclause89 self-assigned this May 15, 2025
@Phillyclause89 Phillyclause89 added the enhancement New feature or request label May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant