An intelligent robotic system that plays checkers autonomously using computer vision and robotic manipulation
ACB-CHECKER is a complete robotic system that autonomously plays checkers by:
- Detecting board state using YOLOv5 computer vision
- Calculating optimal moves using AI algorithms
- Executing moves with a custom-designed RRR manipulator
- Providing an interactive PyGame interface for human interaction
- Real-time board detection using YOLOv5 deep learning
- Piece classification (black/white, king/regular)
- Camera calibration and perspective correction
- Confidence scoring and error handling
- Custom RRR (Revolute-Revolute-Revolute) manipulator design
- Forward/inverse kinematics implementation
- Smooth trajectory planning and obstacle avoidance
- Hardware control via Arduino/Serial interface
- Real-time camera preview with detection overlay
- Interactive PyGame GUI with move validation
- Game state visualization and history tracking
- AI vs Human and AI vs AI game modes
- 3D kinematics simulation using Blender models
- Workspace analysis and optimization
- Performance metrics and logging
- Move prediction visualization
graph TD
A[Camera Input] --> B[YOLOv5 Detection]
B --> C[Board State Extraction]
C --> D[Game AI Engine]
D --> E[Move Validation]
E --> F[Trajectory Planning]
F --> G[Forward Kinematics]
G --> H[Inverse Kinematics]
H --> I[Servo Control]
I --> J[RRR Manipulator]
J --> K[Piece Movement]
L[PyGame Interface] <--> D
M[User Input] --> L
- USB Camera (1080p recommended)
- Custom RRR manipulator (see
hardware/for designs) - Arduino Uno/Mega for servo control
- Computer with CUDA-capable GPU (for YOLOv5 acceleration)
- Python 3.8+
- OpenCV 4.x
- PyTorch 1.10+
- PyGame 2.3+
- Blender 3.0+ (for simulations)
# Clone the repository
git clone https://github.com/abelyo252/ACB-CHECKER.git
cd ACB-CHECKER
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Download YOLOv5 weights
python scripts/download_weights.py
# Calibrate your camera (first-time setup)
python scripts/camera_calibration.pypython Checkerboard.py# Run with different configurations
python Checkerboard.py --mode human_vs_ai # Play against AI
python Checkerboard.py --mode ai_vs_ai # Watch AI vs AI
python Checkerboard.py --mode simulation # 3D simulation only
python Checkerboard.py --mode calibration # Camera calibrationpython Checkerboard.py \
--camera 0 \ # Camera index
--confidence 0.8 \ # Detection confidence threshold
--ai-depth 3 \ # AI search depth
--simulation \ # Enable 3D simulation
--log-level INFO # Logging levelACB-CHECKER/
├── src/
- 3D Print Parts: All STL files are in
hardware/cad/ - Assemble Mechanics: Follow assembly guide in
docs/hardware_guide/ - Wire Electronics: Connect servos to Arduino as per schematics
- Upload Firmware: Load
hardware/firmware/arduino.ino - Calibrate: Run
python scripts/hardware_calibration.py
The RRR manipulator consists of three revolute joints. The end-effector position
The complete transformation from base to end-effector:
Where:
-
$\theta_i$ : Joint angle -
$d_i$ : Link offset -
$a_i$ : Link length -
$\alpha_i$ : Link twist
# Forward kinematics example
def forward_kinematics(theta1, theta2, theta3):
# DH parameters for RRR manipulator
dh_params = [
{'theta': theta1, 'd': d1, 'a': a1, 'alpha': alpha1},
{'theta': theta2, 'd': d2, 'a': a2, 'alpha': alpha2},
{'theta': theta3, 'd': d3, 'a': a3, 'alpha': alpha3}
]
# Compute transformation matrices
T = compute_transformation(dh_params)
# Extract end-effector position
x, y, z = extract_position(T)
return x, y, zThe YOLOv5 model detects checkers pieces with bounding boxes:
Where:
-
$(x_c, y_c)$ : Bounding box center coordinates -
$(w, h)$ : Width and height -
$c$ : Confidence score
The detection loss function combines localization, confidence, and classification:
$$ \mathcal{L} = \lambda_{\text{coord}} \sum_{i=0}^{S^2} \sum_{j=0}^{B} \mathbb{1}_{ij}^{\text{obj}} \left[ (x_i - \hat{x}_i)^2 + (y_i - \hat{y}_i)^2 \right] \
- \lambda_{\text{coord}} \sum_{i=0}^{S^2} \sum_{j=0}^{B} \mathbb{1}_{ij}^{\text{obj}} \left[ (\sqrt{w_i} - \sqrt{\hat{w}_i})^2 + (\sqrt{h_i} - \sqrt{\hat{h}_i})^2 \right] \
- \sum_{i=0}^{S^2} \sum_{j=0}^{B} \mathbb{1}_{ij}^{\text{obj}} (C_i - \hat{C}_i)^2 \
- \lambda_{\text{noobj}} \sum_{i=0}^{S^2} \sum_{j=0}^{B} \mathbb{1}_{ij}^{\text{noobj}} (C_i - \hat{C}_i)^2 \
- \sum_{i=0}^{S^2} \mathbb{1}{i}^{\text{obj}} \sum{c \in \text{classes}} (p_i(c) - \hat{p}_i(c))^2 $$
World coordinates
\mathbf{K} \begin{bmatrix} \mathbf{R} & \mathbf{t} \end{bmatrix} \begin{bmatrix} X_w \ Y_w \ Z_w \ 1 \end{bmatrix} $$
Where:
-
$\mathbf{K}$ : Camera intrinsic matrix -
$[\mathbf{R} | \mathbf{t}]$ : Extrinsic parameters (rotation and translation)
The checkers board state is represented as an
Where
-
$-2$ : Black king -
$-1$ : Black piece -
$0$ : Empty square -
$1$ : White piece -
$2$ : White king
# Simplified detection pipeline
image = capture_frame() # Capture from camera
detections = yolov5.detect(image) # YOLOv5 object detection
corners = find_board_corners(detections) # Locate board
perspective = warp_perspective(corners) # Correct perspective
pieces = classify_pieces(perspective) # Classify pieces
state = extract_board_state(pieces) # Extract game state- Algorithm: Minimax with Alpha-Beta pruning
- Depth: Configurable search depth (default: 3)
- Evaluation: Piece advantage, board control, king potential
- Optimization: Move ordering, transposition tables
| Metric | Value | Description |
|---|---|---|
| Detection Accuracy | 98.2% | Piece classification accuracy |
| Move Execution Time | 2.3s | Average time per move |
| AI Win Rate | 85% | Against human players |
| Workspace Coverage | 85% | Manipulator reachable area |
| Frame Rate | 30 FPS | Real-time processing |
- Mathematical Derivation - Complete kinematics analysis
- Hardware Assembly Guide - Step-by-step build instructions
- API Reference - Code documentation
- Training Guide - How to train your own detector
- Troubleshooting - Common issues and solutions
We welcome contributions! Please see our Contributing Guidelines for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
# Install development dependencies
pip install -r requirements-dev.txt
# Run tests
pytest tests/
# Build documentation
cd docs && make html| Issue | Solution |
|---|---|
| Camera not detected | Check camera index, try --camera 1 |
| Low detection accuracy | Recalibrate camera, adjust lighting |
| Robot not moving | Check Arduino connection, calibrate servos |
| Slow performance | Enable GPU acceleration, reduce AI depth |
See Troubleshooting Guide for more solutions.
If you use this project in your research, please cite:
@software{acb_checker_2023,
title = {ACB-CHECKER: Autonomous Checkers Playing Robot},
author = {Abel Yohannes},
year = {2023},
url = {https://github.com/yourusername/ACB-CHECKER}
}- Ultralytics for the YOLOv5 implementation
- Blender Foundation for 3D modeling tools
- OpenCV community for computer vision libraries
- All contributors who helped improve this project
This project is licensed under the MIT License - see the LICENSE file for details.
Abel Yohannes - @ForAbel252
Project Link: https://github.com/yourusername/ACB-CHECKER
# Contributing to ACB-CHECKER
Thank you for your interest in contributing! Here's how you can help...
## Development Process
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests
5. Update documentation
6. Submit a pull request
## Code Style
- Follow PEP 8 for Python code
- Use type hints where possible
- Write descriptive commit messages
- Include docstrings for functions




