Skip to content

kaushik2107-bit/chess-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

CHESS ENGINE

A basic chess engine built on C++ with a lot of room for work.

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Contributing
  5. Contact

About The Project

This chess engine is build on C++. It's a chess engine (room for optimization) that uses 12 bitboards and a piece_tracker map to take care of the position of a piece in a chessboard. To suggest a new move, it uses a minimax algorithm with alpha-beta optimization and an evaluation function to determine the best move. It also use a move ordering principle to look at better moves first.

Getting Started

This is an example of how you may set up your project locally. To get a local copy up and running follow these simple example steps.

Prerequisites

This is an example of how to list things you need to use the software and how to install them.

  • c++
    • You must have c++ compiler install in your system.

Installation

  1. Clone the repo
    git clone https://github.com/kaushik2107-bit/chess-engine.git

Usage

  1. To start chess (Make sure all the header files lie in the same folder)
    #include "chess.h"
    
    int main() {
        Chess chess;
        // Chess chess("rnbq1rk1/pppn1ppp/4p3/3pP3/1b1P4/2NB1N2/PPP2PPP/R1BQK2R w KQ - 0 1");
        // You can also provide a fen position
        Move& board = chess.board;
    }
  2. Generating all pseudo legal moves
    board.generate_pseudo_legal_moves()
    // This function will return a std::vector<std::string> consisting of all the candidate moves
  3. Generating all legal moves
    board.generate_legal_moves()
    // This function will return a std::vector<std::string> consisting of all the legal moves in that position
  4. Printing chessboard in the console
    board.print_chessboard(board.bitboard);
    // This is a void function which prints the chessboard in the console.
  5. Analyzing a position
     std::pair<std::pair<std::string, int>, int> result = chess.analyze(board, 3);
    // The parameter is the object board and depth
    // This function returns 3 things. First - Best Move, Second - Evaluation, Third - Nodes covered
  6. Making a move
     board.push("e2e4");
    // The parameter is the move in std::string in uci notation.
  7. Revoking a move
     board.pop();
    // It removes a move from the board. But if there was no move made before, it will throw an **out of index** error

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Contact

Your Name - @twitter_handle - [email protected]

Project Link: https://github.com/kaushik2107-bit/chess-engine

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages