Skip to content

andyyu/chrome-chess-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chrome Chess Bot

Chrome Web Store Chrome Web Store

A chess bot for Chess.com written in Javascript and designed as a Chrome extension. Uses the open-source Stockfish engine for its move analysis. Automatically registers game start/completion, parses game state on a per-move basis, and produces the best move after analyzing outcomes 14 moves deep.

14 is default, this can be changed in background.js to sacrifice move calculation speed for better performance.

A search limit of 14 takes ~0.75-1 second per move.

Warning: increasing max search depth will exponentially increase computation time.

Tested (to win) on defaults settings up to ~2000 Elo.

gif1

Download from the Chrome Web Store, or add it as a local extension by cloning the repo and visiting chrome://extensions.

Warning: Extensive use of this bot will likely result in account closure. Use at your own risk.

How Does It Work?

This Chrome extension contains 3 main components: a background script running the bulk of my logic background.js, a content script bot.js, and another script injected into the webpage inject.js.

The injected script adds an event listener to the page's XMLHttpRequest object, that intercepts any messages sent by the chess.com server to the client. It then parses any requests indicating a played move sent by the server and routes it to the content script. The content script acts as a message controller / relay, listening for any messages from the injected script or background script and relaying it to the appropriate handler. My background script is running a variation of the Stockfish engine in a web worker, and contains a Chrome runtime listener for any messages sent by the content script. Once a new move has been received, it runs through my handling logic and spits out the best move to the content script, which then displays it on the page.

TODO

  • Automatic move completion (difficult due to chess.com obfuscation)
  • Bugs:
    • Event listener sometimes doesn't catch the HTTP response containing the move.
    • Non-Queen promotions don't work properly.
    • Tile highlighting scaling breaks when browser window is resized mid-game.

About

Chess.com bot - Chrome Extension

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published