Have you ever wanted to play chess but didn’t have anyone to play with? Now you can play against a virtual opponent using a real chess board thanks to this Raspberry Pi project put together by maker and developer Noah Davis. Not only does this Pico-powered chess-playing robot simulate having a real opponent, it brings your challenger to life by adding ChatGPT to throw insults at you while you play and uses Stockfish to cheat by optimizing its moves against you.
The project mainly uses ChatGPT to add dialogue using text-to-speech functionality. After all, who wants to play against a silent opponent when you could program them to be super sassy and toss out insults in the middle of your match?
The Raspberry Pi team reached out to Davis to get some more information about how it works and published the details in a recent blog post. The board is fitted with an array of Hall effect sensors that determine where pieces are placed. The chess pieces have magnets on the bottom to trigger the sensors underneath. But this doesn't identify what the pieces are, so Davis wrote some code to track the position of every piece, from its starting to end position.
In addition to the magnets and sensor array, Davis created a robotic arm that can pick up pieces and move them. The arm position is transmitted to the Raspberry Pi Pico using a serial connection which is interpreted to process the next move position. LEDs installed on the side of the board signify whose turn it is.
The lights will illuminate blue on the side of whoever’s turn it is to make a move. When it’s time for the virtual opponent to make a play, the Pi connects to an open-source chess-playing application called Stockfish. This is where the cheating comes into play. It uses Stockfish to plan the perfect move making it a more than difficult adversary.
If you want to see this Raspberry Pi project in action, you can check it out over at YouTube. There are plans to upload a new video with more details in the near future. In the meantime, you can find a behind-the-scenes look at its construction over at the official Raspberry Pi blog.