AI-based Chess Validator

by dmytroyolkin in Circuits > Assistive Tech

42 Views, 1 Favorites, 0 Comments

AI-based Chess Validator

photo_2025-06-20_00-55-25.jpg
photo_2025-06-14_11-31-06.jpg

An AI-based chess validator is an intelligent system designed to automatically verify the correctness of chess moves. By combining computer vision and artificial intelligence algorithms, it recognizes the positions of pieces on the board and checks them against the official rules of the game, ensuring accurate monitoring and fair play.

Supplies

51hNx7-VFYL.jpg
51hV9+Jc2SL._SL1000_.jpg
61LEHVIkRpL._AC_SL1076_.jpg
buttons_1.jpg
RaspberryPi_Raspberry_Pi_5_4_GB_SC1111_DAR01229_m1_big.jpg
RaspberryPi_Raspberry_Pi_5_USB-C_voeding_wit_27W_4263039_SC1152_DAR01233_m1_big.jpg
61HIu9VrwSL._SL1500_.jpg
photo_1750325896.jpg

Hardware

  1. Raspberry Pi 5
  2. MicroSD card (32 GB)
  3. Raspberry Pi power supply 5V
  4. USB Camera
  5. Raspberry Pi LCD display
  6. OcioDual 3 x Buzzer 5V Active Buzzer
  7. 2x arcade buttons
  8. 2x touch buttons
  9. 2x 4 Digit LED Segment Display
  10. Jumper wires and breadboard
  11. Wooden box with slots for wires and previously written electronics (laser-cutting)


Software

  1. Raspberry Pi OS (64-bit)
  2. Python 3.10+
  3. OpenCV
  4. Ultralytics (for YOLOv11)
  5. Gradio
  6. RPi.GPIO
  7. Python script
  8. sqlite3 database

Prototype Preparation: Creating the Idea + Exterior Model

Start by defining your project’s purpose—what it does and why it matters. I sketched the concept, showing the layout and how users will interact with it. Then, I gathered simple materials like cardboard, glue, and markers to build a physical model of my idea. This mock-up should resemble the final shape and design, helping you visualize size, button placement, and usability. Tested the model, gather feedback, and adjust the design before moving on to electronics—this step bridged my imagination with a tangible starting point.

Basic Raspberry PI Setup

Before starting on the main prototype, we had to prepare our Raspberry Pi by completing the basic setup:

  1. Install the Operating System
  2. We flashed the Raspberry Pi OS onto a microSD card using tools like Raspberry Pi Imager. After inserting the SD card into the Pi, we booted it up and completed the first-time setup.
  3. Connect to the Internet

This step ensured the Raspberry Pi could:

  1. Download updates
  2. Install required software packages
  3. Enable remote access (via SSH)

AI Model Selection & Dataset Preparation

To bring intelligence to our project, we needed to choose an appropriate AI model and a reliable dataset:

  1. Define the Task
  2. First, we clarified what the AI should do — detect objects (bounding boxes)
  3. Select the AI Model
  4. Based on the task and available resources (like compute power), we chose a suitable model architecture.
  5. For image recognition: YOLOv11-s (small version, because it is fast and accurate enough for my purposes)
  6. Choose or Collect a Dataset
  7. We created our own dataset by collecting and labeling images specific to our project.
  8. Preprocess the Dataset
  9. We resized images, and split the data into training, testing and validation sets to prepare (+augmented) it for model training.


Model Training and Position Detection

confusion_matrix_normalized.png

The AI system is capable of detecting all 12 types of chess pieces — six for each color (white and black). It identifies not only the piece type and color but also their exact positions on the board by locating their bounding boxes (coordinates), enabling precise tracking of the game state.

1. Model Training

We trained the AI model using our prepared dataset, adjusting parameters to improve accuracy in recognizing chess pieces and board states.

2. Position Detection

The trained model processes images of the chessboard to detect the position of each piece, converting visual input into a digital board representation for game analysis and validation.

Laser Cutting

photo_2025-06-14_11-31-14.jpg

I designed the model in Inkscape and prepared the file for laser cutting.

Material used: 4 mm thick plywood.

🔹 In Inkscape, I:

  1. Marked holes for electronics
  2. Engraved the text "AI-based chess validator"
  3. Created cut outlines

The file was then sent to the laser cutter, and the case was cut and assembled.

Soldering and Electronics Connection

photo_2025-06-17_13-13-07.jpg
photo_2025-06-14_11-31-11.jpg

I soldered the necessary components and wires to ensure stable connections. For easier prototyping, I connected the Raspberry Pi’s GPIO pins to a breadboard, which allowed flexible wiring without permanent soldering.

On the breadboard, I arranged components like sensors and LEDs, connecting them to the corresponding GPIO pins on the Raspberry Pi for testing and development.

Core Code

I developed the main program to handle:

  1. Arcade buttons for user input
  2. Reset/Stop buttons to control the game
  3. LCD display to show status and messages
  4. Gradio interface for live visualization and previous moves tracking (previous/next buttons through gradio UI)
  5. Database integration to save and load game states and moves for tracking and analysis

This setup links hardware, software, and data storage, ensuring smooth interaction and persistent game history.

Testing and Problem-solving

During testing, I identified issues like timer inaccuracies, LCD display glitches, and logical errors in game flow.

I systematically debugged by:

  1. Checking wiring and connections
  2. Reviewing and correcting the code logic
  3. Using print statements and logs to trace errors
  4. Adjusting timer settings and LCD update routines

This process ensured stable operation and reliable user experience.