The Chess Robot is a fully functional robotic system capable of physically playing chess on a real-world chessboard. It autonomously detects player moves and responds with its own moves using robotics, chess engine logic, and a custom-designed printable circuit board (PCB). The system operates through a 2-axis gantry for X and Y movement, a linear actuator with an electromagnet for Z-axis control, and magnetic piece detection using reed sensors under the chessboard.
This project was created by the Haverford Electronics Group with support from The Haverford School.
Haverford Electronics Group members Finn Kelly (left) and Jack Ford (right) posing with the robot
News Article: https://thsindex.org/2024/10/15/soft-robotics-designschess-playing-robot/
- Autonomous Chess Play: Plays chess autonomously against a human player.
- Player Move Detection: Uses magnetic reed sensors wired to a custom PCB beneath the chessboard to detect player moves.
- Robot Movement: Precisely moves chess pieces using a gantry system with X, Y, and Z-axis control, combined with an electromagnet for gripping pieces.
- Chess Engine: Uses chess engine logic to calculate the robot's next move.
- Custom GUI: Provides real-time status, game settings, and control over the robot.
- The player moves chess pieces on the board, which activates magnetic reed sensors beneath each square.
- An Arduino MEGA connected to a custom PCB receives signals from the reed sensors and sends them via serial.
- The
BoardInput
class communicates with the Arduino MEGA to receive the updated board state. - The system tracks changes in the board state to identify the origin and destination squares of the player's move.
- Error correction is added to improve the robot's reliability even if the sensors malfunction.
- The new board state is processed by a chess engine to calculate the best response.
- This engine can be set to easy, medium, or hard.
- By default the robot runs Stockfish 17 but a custom chess engine can be used instead.
- The robot's gantry system uses GRBL commands to move to the starting position of the piece.
- The Z-axis actuator lowers the electromagnet to pick up the piece magnetically.
- The robot moves it to the target square and turns off the electromagnet to release the piece.
- The robot is always sent home after every move to ensure safety.
ChessRobot/
├── external/ # External libraries (e.g., chess logic, serial communication)
├── headers/ # C++ header files for core logic, hardware control, etc.
├── src/ # C++ source files containing the main implementation
├── assets/ # Asset files (GUI images, resources)
├── CMakeLists.txt # CMake build configuration
└── conanfile.txt # Conan package configuration
- CMake 3.16 or higher.
- Conan package manager.
- C++17 compiler.
- Raspberry Pi 3 Model B
- Clone the repository:
git clone https://github.com/your-username/ChessRobot.git cd ChessRobot
- Install dependencies using Conan:
conan install .
- Build the project using CMake:
mkdir build && cd build cmake .. make
- Upload the Arduino sketch to the Arduino board.
- Turn on the Chess Robot.
- Launch the ChessRobot executable from
home/programming/ChessRobot/build/build/Release
. - Connect the machine and board via the GUI.
- Use the GUI to:
- Start a new game.
- Adjust engine difficulty.
- View game status and machine coordinates.
- Play a move on the physical chessboard. The robot will detect the move, calculate its response, and physically move the pieces using the gantry system and electromagnet.
Contributions are welcome! If you'd like to report issues or suggest improvements, please open a GitHub issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
With this Chess Robot, you'll experience a unique blend of robotics, chess strategy, and software engineering. Watch as the robot plays chess with precision and intelligence, blending human input with robotic execution.