Subsystem 2: Ai - miloboyd/chess-robot GitHub Wiki

AI Subsystem - Stockfish Integration



Overview

The Ai subsystem interprets the current chessboard state using FEN strings and returns an optimal move using the Stockfish chess library. It serves as the core decision making unit of the robotic chess system.

This subsystem integrates with:

  • Vision system - for receiving real time board state (FEN)
  • Robot arm control - for executing the chosen move
  • GUI - for adjusting the AI difficulty

Inputs & Outputs

Type Source Description
Input Vision Subsystem FEN string representing current boards
Process Stockfish Evaluate best move from input
Output Robot Arm Move in algebraic notation (eg e2e4 : the notation will also have either a 1 or a 0 at the end to identify it a piece needs to be removed from the board or not before the move is completed. So an example would be e2e40)

Dependencies

Hardware

  • No hardware specifically related to AI subsystem, however it interacts with:
    • UR3e + RG2 Gripper
    • RGBD Camera
    • Custom chessboard

Software

Name Version
Python 3.13+
ROS2 Humble
Stockfish Python pypi.org/project/stockfish

Installation

To install the requirements for the AI subsystem please copy the following commands

Install Stockfish

sudo apt install stockfish

pip install stockfish


Configurable Parameters

The Ai subsystem is making the Skill Level adjustable. The skill level can be adjusted via the GUI before the match begins and will impact the results calculated on a scale from 1-20 with the higher number relating to a more advanced move generated.


Troubleshooting

Below are some issues that could occur and their solutions.

Problem Fix
Ai returns no move Check FEN string format
Move returned is invalid Validate inputted FEN matches actual board
No response from Ai Confirm Stockfish is installed
Ai not receiving FEN Check vision system is sending it a valid FEN string
⚠️ **GitHub.com Fallback** ⚠️