Skip to content

A C# chess bot for Sebastian Lague's Chess Coding Challenge. Utilizes bitboard representations with Zobrist hashing for rapid state evaluations, a curated opening book for optimized early-game play, and iterative deepening with alpha-beta pruning for depth-adjusted search, and more.

License

Notifications You must be signed in to change notification settings

redayzarra/KnightVision

Repository files navigation

KnightVision - Chess Bot

KnightVision forks my girlfriend

KnightVision forks my girlfriend.


KnightVision wins a chess match against my girlfriend

KnightVision checkmates my girlfriend.

Overview

KnightVision is a chess bot created for the Chess Coding Challenge. Built with C# using the .NET 6.0 framework, this bot focuses on adapting to opponent moves and ensuring efficient performance within the competition's 256MB memory limit. KnightVision employs sophisticated strategies to play strong chess while adhering to the competition's rules and constraints.

What the Bot Does

KnightVision uses a combination of advanced techniques to make its moves:

  1. Opening Book:

    • The bot leverages a compact opening book to guide early-game play, utilizing a dictionary to store common openings and defenses. This ensures efficient opening moves without consuming excessive memory.
  2. Iterative Deepening:

    • KnightVision employs iterative deepening to search for the best moves, gradually increasing the depth of its search until it finds the optimal move within the time constraints.
  3. Negamax Algorithm with Alpha-Beta Pruning:

    • The core of the bot's decision-making process is based on the Negamax algorithm enhanced with alpha-beta pruning. This technique efficiently searches the game tree to evaluate the best possible moves while pruning suboptimal branches to save time.
  4. Transposition Table:

    • The bot uses a transposition table to cache board states and avoid recalculating positions it has already evaluated. This optimization significantly speeds up the search process.
  5. Quiescence Search:

    • To avoid the horizon effect, KnightVision employs quiescence search, which extends the search depth for capturing moves to ensure a more stable evaluation of positions.
  6. Move Ordering:

    • Moves are ordered using a heuristic that prioritizes captures (most valuable victim and least valuable attacker) and historical data, improving the efficiency of the alpha-beta pruning.
  7. Evaluation Function:

    • The bot uses a sophisticated evaluation function that takes into account various factors such as material balance, piece activity, king safety, and pawn structure. Precomputed evaluation weights are used to quickly assess the value of different positions.
  8. Endgame Knowledge:

    • KnightVision has specific strategies for endgame play, including recognizing basic endgame patterns, detecting stalemate scenarios, and adjusting its evaluation function to prioritize critical endgame principles like king centralization and pawn promotion.

Usage

  1. Clone the repository:

    git clone https://github.com/redayzarra/KnightVision.git
  2. Navigate to the project:

    cd KnightVision\Chess-Challgenge
  3. Build the project:

    dotnet build
  4. Run the project:

    dotnet run

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgments

For any questions or contributions, please contact the project maintainer or open an issue on the GitHub repository.

About

A C# chess bot for Sebastian Lague's Chess Coding Challenge. Utilizes bitboard representations with Zobrist hashing for rapid state evaluations, a curated opening book for optimized early-game play, and iterative deepening with alpha-beta pruning for depth-adjusted search, and more.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published