Skip to content

Latest commit

 

History

History
37 lines (22 loc) · 3.23 KB

README.md

File metadata and controls

37 lines (22 loc) · 3.23 KB

Knightr0's Gambit

Overview

This repository hosts the code for Knightr0's Gambit, a University of Central Florida AI / IEEE collaboration to create an automatic chessboard (similar to Harry Potter's Wizard Chess with less violence) powered by a custom chess AI.

Project webpage, project overview doc

How it works

The main program is game.py (located in firmware/raspi/). This code is the entry point to interacting with the chessboard; it runs a loop that keeps track of game state (whose turn it is, past moves, etc.), computes moves using a custom chess AI, and processes images taken of the board to compute board state after the player moves a piece. This driver program has options for over-the-board play, a command-line interface, and a web interface. We plan to add a voice interface at a later point.

The game.py program runs on a Raspberry Pi, and interacts with arduino code that controls the actuators of the chessboard, the four interfaces (one-at-a-time) described above, a custom AI modeled after Deepmind's AlphaZero, and a computer vision system which keeps track of the current chessboard state.

The arduino code (located in firmware/arduino/chessboard) runs on an ESP32 microcontroller. Once the AI move has been computed on the Raspberry Pi, it is converted to a standardized message format and sent to the ESP32 microcontroller using UART serial communication. The microcontroller then actuates the physical board mechanism (motors and electromagnet) and sends back status messages indicating current state of the board/microcontroller. UART serial communication is used as it allows us to easily send data in both directions.

The AI is modeled after Deepmind's AlphaZero.

To learn each game, an untrained neural network plays millions of games against itself via a process of trial and error called reinforcement learning. At first, it plays completely randomly, but over time the system learns from wins, losses, and draws to adjust the parameters of the neural network, making it more likely to choose advantageous moves in the future.

The trained network is used to guide a search algorithm – known as Monte-Carlo Tree Search (MCTS) – to select the most promising moves in games. For each move, AlphaZero searches only a small fraction of the positions considered by traditional chess engines. In Chess, for example, it searches only 60 thousand positions per second in chess, compared to roughly 60 million for Stockfish.