A little late into the pandemic I found myself getting obsessed with chess once again. I would spend countless hours on playing chess and pushing my rating up - higher and higher. I felt my passion for chess to be purposeless. To justify the countless hours I'd been putting in studying chess, I started working on my own Chess AI.

What it does and How I Built it

After evaluating the best outcome, the move is played on the main chess board. When the computer plays it’s move, the computer’s clock stops ticking and the player’s clock starts. When the player drops his/her piece on the chess board, the JavaScript uses Ajax query to communicate the player’s move to the back-end. The current game fen is first validated by the program, and then the computer stores the current game’s FEN (Forsyth–Edwards Notation), player’s time left, computer’s time left, game status (in progress, checkmate, draw, etc.), a list of moves and a few other details in a MySQL table using Django Models. After the game record in the MySQL table has been updated, the computer evaluates it’s move and then plays it on the main board. When the game ends, it is updated on the MySQL record and displayed on the front-end. If the player quits in between, the record is unchanged. Hence, the game is being auto-saved or backed up after every move in the MySQL table. On the home page, the player can view their games that are in progress or games that are already completed. If the player decides to continue a game, they can do so from where they left off. The game that is continued is also automatically saved after every move. Auto-saving the game gives players the freedom to pause the game at any moment and get back to it from where they dropped off. After a game has been completed, the player can still view it. This helps the player analyze the game and improve by learning from the computer’s moves. This also allows the player to keep a track of the number of games played in a single day. While viewing, the player also has access to the game FEN which can be shared online with friends. The player can also choose to delete any of their games (either in progress or completed) from the home page. Only the games the player chooses to keep are stored in the MySQL table. Hence, Django Model connectivity with MySQL, which allows the backup and viewing functionality, is crucial to for Chess Bot.

What's next for AI Chess Bot

1. Game Analyzer: At the end of the game, the Chess Bot returns statistics comparing the best move versus the player’s move. This will help players learn from the Chess Bot and improve their game play. The Analyzer also generates a report of all the blunders, mistakes and the missed win opportunities of the player to train the player.

2. Support multiple Skill sets: The Chess Bot will support a range of skill sets from novice to Grand Master to better match the player’s level. This will also encourage the player to challenge higher level Bots.

3. Learning from Player: The Chess Bot might also use machine learning to understand Human Behaviour and learn from it’s past games to improve it’s own skills.

4. Game Information: Chess Bot will also identify and provide information about the Chess opening that is played at the start of the game. If the Bot recognizes any of the Chess Games or observes any move pattern, it will also display that in the move box. This helps the player learn more about Openings and Popular Chess Games to improve their own knowledge.

Share this project: