Git Product home page Git Product logo

ashchess-chess-engine's Introduction

AshChess Chess Engine

A fun Chess Engine Written in C++.

License

Description

This is a relatively simple chess engine implemented in [C++]. It allows you to play chess against the engine, analyze games, and play the best move in puzzles (custom positions).

Features

  • Play against the engine
  • Set timely moves, I.e., enter a time 'x' seconds, and the best move that could be made in x seconds would be made by the Engine
  • Game analysis
  • Simple function calls, that can be implemented in APIs.
  • Uses Multi-Threading Features in C++.

Installation

Step 1: Clone this Repository

git clone https://github.com/Ashrayyy/AshChess-Chess-Engine.git

That's it, compile the project.

Note: The w64 MinGW Compiler will not be able to compile the project, you need to add future and threading libraries manually (or install a posix build of MinGW with multithreading support)

Usage

Run the Program

You can set time per move, or set the position in the code.

An infinite loops run that always waits for inputs enter 0 for the engine to make the move enter 1 for making a manual move. enter 2 for skipping a turn (for development and debugging purposes (and for special moves like en-passant))

Credits

This Chess engine was a fun project, I love chess and I wanted to make some project related to the game.

The input move format is Universal Chess Interface (UCI)

The Opening file contains openings picked from Chess-poster's Website and also from Tom Kerrigan's SCP. Kudos to LiChess for the great Master Database to pick and add selective Openings!

References

This Engine DOES NOT USE BITMAPS to represent the chessboard. It uses a 2d vector to display the ChessBoard and evaluated positions on the basis of basic and advanced heuristics. These refereces sure got me a better understanding to complete the project.

Games

I am a 1700+ on Chess com and this was one of the few games I won, after sacrificing a Rook, a Bishop and then a Knight. This game was played at an early stage while developing the bot, when it didn't even had complex moves like castling and pawn promotions introduced.

How it works

Openings

When a game starts, the openings get loaded in a Trie Data Structure, I have also added the first 6 best moves from the Lichess Master Database into the openings. It randomly chooses the available options as per the previous moves.

What if I want to add my own openings to the opening Trie

It is simple, either just place UCI notations in the openings.txt file. Or if you have PGN, paste it into openingsGeneralNotations.txt and the run the pgn_to_uci.py script to get UCI notations in openingsUCInotation.txt, then you can copy and paste the UCI notations of openings into openings.txt!

As the game proceeds, the opening Trie gets searched on, once the nextTrie vector is empty (on reaching a terminal node), the engine does start calculating.

Calculating, how?

The Engine utilizes recursion techniques and advanced versions of the MiniMax algorithm and several Pruning techniques including Alpha-Beta Pruning to reduce the branching factor and prune not-so-good branches. and evaluates terminal nodes.

Evaluation, how?

The engine evaluates chess board position on the basis of heuristics (since computers can not get intutions as humans do).

I have tried to add comments at specific points to make the code more understandable, however for any doubts, you can reach out to me!

Contact

In case you want to contribute to the project, or if you have any queries, you can Email me or dm me at my LinkedIn !

ashchess-chess-engine's People

Contributors

ashrayyy avatar

Stargazers

 avatar Aditya Kumar avatar Supriya Patidar avatar Deepak avatar Anubhav Dhyani avatar Ambrish Tripathi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.