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.
KnightVision uses a combination of advanced techniques to make its moves:
-
- 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.
-
- 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.
-
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.
-
- 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.
-
- 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.
-
- 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.
-
- 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.
-
- 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.
-
Clone the repository:
git clone https://github.com/redayzarra/KnightVision.git
-
Navigate to the project:
cd KnightVision\Chess-Challgenge
-
Build the project:
dotnet build
-
Run the project:
dotnet run
This project is licensed under the MIT License. See the LICENSE file for details.
- Thanks to the Chess Coding Challenge for inspiring this project.
For any questions or contributions, please contact the project maintainer or open an issue on the GitHub repository.