Table of Contents
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.
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.
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.
- Clone the repo
git clone https://github.com/kaushik2107-bit/chess-engine.git
- 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; }
- 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
- 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
- Printing chessboard in the console
board.print_chessboard(board.bitboard); // This is a void function which prints the chessboard in the console.
- 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
- Making a move
board.push("e2e4"); // The parameter is the move in std::string in uci notation.
- 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
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!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Your Name - @twitter_handle - [email protected]
Project Link: https://github.com/kaushik2107-bit/chess-engine