My chess robot has been an on-and-off hobby project which is now finally ready to show off. It has been over 7 years in the making!
Since I started on the idea (originally using a Duemilanove), I see that a quite a few similar projects have been completed. However there are a few elements to my implementation which were original design objectives which (I think) still make it worthwhile:
- No external devices/laptops - all electronics are packaged under the board with board detection, chess engine and arm control all running off a single Arduino Due
- Generous board size - 32cm x 32cm board for comfortable human playing (requiring arm to have 410cm reach, significantly greater than the largest Lynxmotion arm, the AL5D)
- 'Living room ready' - finished as a low maintenance and easy to use display item, which can sit out on a coffee table (requiring single mains power connector)
Chess playing strength was not a huge focus for the project and could be improved with longer playing time or other optimisations, but is already sufficient to beat most visitors (plays about 1400 elo with only a few seconds per move).
Here's a picture of the finished robot in its new home and a video of it in action (with explanations):Youtube link
The project divides into three main components and here's a quick overview of each:1. Robot Arm
From the start one of my key objectives was to achieve as accurate, smooth and reliable arm movement as possible. I quickly realised that the size of my board would make this quite challenging for standard hobby servos and arm kits that were readily available.
The arm is built using basic framework components from Lynxmotion but with a customised rotating base and limb chassis to try to minimise the play in the arm from its target position. To provide the level of accuracy I needed on an arm with reach over 40cm, the elbow and shoulder servos are 7.4v digital Hitec servos. It's obviously not surgical grade but I'm pretty happy with the result.2. Board Detection
Pieces are detected using 4mm magnets in their bases and an array of 64 reed switches under the board, read into a single pin on the Arduino by cycling through a series of 8 shift registers.
Reed switches are aligned perpendicular to the board, as this allowed me to drill straight into the board and position the switches as close as possible to the surface. This minimised the required strength of the magnets and eliminate the risk of adjacent squares being incorrectly triggered. I also found that this orientation was best to avoid any issues with the polarity of the magnets, ensuring that switches are closed whatever the orientation of the chess piece.3. Chess Engine
The engine is based on the remarkable micro-Max chess by H. G. Muller (http://home.hccnet.nl/h.g.muller/max-src2.html
), which is a full working chess engine smaller than 2KB in size. Although I have written a working chess engine before, that was not the main focus of the project so I wanted to use a lightweight and robust c++ engine as my starting point. I was able to get it going quite quickly on Arduino and build in the required 'hooks' to interface with the board and arm, without needing any modifications to the main engine. I did have trouble using the hash table versions on a Duemilanove due to memory restrictions, so I'm currently using version 1.6 (which uses no hash). Now that I've switched to a Due it might be possible to work with a hash table, which could allow me to use the latest versions and improve playing strength considerably.
Code and support files downloadable here
Thank you to a number of forum contributors who helped me out along the way: LarryD; MarkT; outsider; Grumpy_Mike; Wawa; allanhurst; westfw; david_prentice; Sulimarco