{"id":19644538,"url":"https://github.com/shriniwasmahajan/chess_engine","last_synced_at":"2025-07-08T15:04:20.959Z","repository":{"id":251748154,"uuid":"822557688","full_name":"ShriniwasMahajan/chess_engine","owner":"ShriniwasMahajan","description":"A chess engine built using C++ and the SFML library. This project implements the core logic of chess and a user interface for playing chess against a computer opponent powered by an AI algorithm.","archived":false,"fork":false,"pushed_at":"2024-08-12T20:02:50.000Z","size":566,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-08T15:04:19.288Z","etag":null,"topics":["cpp"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ShriniwasMahajan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-01T11:23:25.000Z","updated_at":"2024-08-13T14:16:09.000Z","dependencies_parsed_at":"2024-08-05T14:11:26.122Z","dependency_job_id":"1da73508-4f78-48ab-abc2-e25f4d4d2168","html_url":"https://github.com/ShriniwasMahajan/chess_engine","commit_stats":null,"previous_names":["shriniwasmahajan/chess_engine"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ShriniwasMahajan/chess_engine","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShriniwasMahajan%2Fchess_engine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShriniwasMahajan%2Fchess_engine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShriniwasMahajan%2Fchess_engine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShriniwasMahajan%2Fchess_engine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ShriniwasMahajan","download_url":"https://codeload.github.com/ShriniwasMahajan/chess_engine/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShriniwasMahajan%2Fchess_engine/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264292907,"owners_count":23586059,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp"],"created_at":"2024-11-11T14:28:20.021Z","updated_at":"2025-07-08T15:04:20.939Z","avatar_url":"https://github.com/ShriniwasMahajan.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# C++ Chess Engine\n\n## Description\nThis is a C++ Chess Engine with an emphasis on user interaction and experience. The engine is designed to play and analyze chess games, featuring smooth animations, an intuitive GUI, and user-friendly controls.\n\n## Features\n- Full chess move generation and validation\n- Drag and drop functionality for making moves\n- Smooth animations for piece movement\n- User-friendly graphical interface\n- Backspace to undo the last move\n- Press 'R' to restart the game\n- Endgame recognition and handling\n- Implementation of key algorithms for chess AI, including:\n  - Minimax algorithm\n  - Alpha-beta pruning\n  - Evaluation function to assess board positions\n\n![Initial Board Setup](https://github.com/user-attachments/assets/fcebc9b9-07af-45d6-b841-c91718c42b8a)\n\n## Usage\n### Playing a Game\nOnce you have compiled the engine, start the game by running the executable. The graphical interface will launch, allowing you to drag and drop pieces to make your moves.\n### Controls\n- Drag and Drop: Use your mouse to drag and drop pieces.\n- Backspace: Press backspace to undo your last move.\n- Restart: Press 'R' to restart the game.\n\n## Example\nHere's an example of how to start the engine and interact with the GUI:\n```$ ./chess_engine```\n\nOnce the game starts, use your mouse to drag and drop pieces to make your moves. If you make a mistake, press backspace to undo the last move, or press 'R' to restart the game.\n\n## Code Structure\nThe code is organized into the following main components:\n1. **main.cpp**: Handles the main game loop, including user inputs, rendering, and overall program flow.\n2. **ai.cpp**: Implements the chess AI with algorithms like Minimax and Alpha-Beta Pruning. Also includes functions for evaluating the board state and detecting endgame scenarios.\n3. **pieces.cpp**: Defines the behavior and movement of individual chess pieces, including the generation of possible moves for each piece.\n4. **board.cpp**: Manages the chessboard's state, including piece positions and move validation. Also includes utility functions for converting positions and handling game restart.\n5. **game.cpp**: Handles the game logic, including move execution, drawing the board, undoing moves, and checking for endgame conditions.\n\n![Midway through a game](https://github.com/user-attachments/assets/39e560cc-fb57-491c-807e-7a0bc1639804)\n\n## Global Variables and Functions\n### board.cpp:\n- board[8][8]: Represents the chessboard with pieces indexed by their position.\n- pieceVals[32]: Stores values associated with the pieces.\n- Various arrays for piece positions (e.g., bRookPos, bKnightPos).\n- Functions for loading positions, converting between chess notation and coordinates, and restarting the game.\n### game.cpp:\n- gameOver: Boolean flag indicating whether the game is over.\n- Functions for drawing the board, making moves, undoing moves, and handling the computer's move.\n### ai.cpp:\n- endGame: Boolean flag for endgame detection.\n- Functions for evaluating the board, checking game over conditions, and implementing the minimax algorithm.\n### pieces.cpp:\n- f[32]: Sprite array for the chess pieces.\n- defeated: Vector for storing defeated pieces.\n- Functions for generating moves for each piece type.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshriniwasmahajan%2Fchess_engine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshriniwasmahajan%2Fchess_engine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshriniwasmahajan%2Fchess_engine/lists"}