Skip to content

sakthilkv/chessbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ChessBot using OpenCV and Stockfish

ChessBot is an intelligent chess-playing application that leverages OpenCV to read the screen, detect a chessboard, and interact with a chess engine (Stockfish) to play moves based on the bot's color.

Features

  • Screen Reading: Uses OpenCV to capture the screen and detect the chessboard.
  • Move Detection: Identifies the current state of the board and detects the opponent's moves.
  • Bot Interaction: Interacts with the Stockfish chess engine to calculate and play the best move.
  • Color-Based Play: Configurable to play as either white or black.

Requirements

  • Python 3.x
  • OpenCV
  • Stockfish engine
  • chess library
  • numpy

Installation

  1. Clone the repository:

    git clone https://github.com/sakthilkv/chessbot.git
    cd chessbot
  2. Install dependencies:

    pip install opencv-python chess numpy
  3. Download Stockfish: Download the Stockfish engine from the official website and place the executable in the project directory.

Usage

  1. Setup and Run:

    python chessbot.py
  2. Input Bot Color: When prompted, input the bot's color:

    • w for white
    • b for black

How It Works

  1. Screen Reading:

    • Captures the screen using OpenCV.
    • Detects the chessboard and extracts the current state.
  2. Move Detection:

    • Compares the current state with the previous state to detect moves.
    • Uses the chess library to validate moves and update the board state.
  3. Bot Interaction:

    • Configures and interacts with the Stockfish engine to get the best move.
    • Plays the calculated move on the screen using OpenCV.
  4. Color-Based Play:

    • The bot plays according to the specified color and waits for the opponent's move before making the next move.

Acknowledgments

  • Stockfish for providing the powerful chess engine.
  • OpenCV for the computer vision library.
  • The Python chess library for chess-related functionalities.

About

Chessbot using OpenCV and Stockfish

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages