This project is a high-performance, fully independent chess engine and library developed from scratch in pure C#. Unlike implementations that rely on external libraries or third-party engines, this codebase was built to provide a deep, fundamental understanding of chess logic, board state management, and algorithmic efficiency.
The engine is designed as a library, meaning it can be easily integrated into any C# application—whether you are building a desktop GUI, a terminal-based game, or an AI analysis tool.
The engine's architecture follows strict Object-Oriented Programming (OOP) principles to ensure that the complex nature of chess is broken down into maintainable, readable, and scalable components:
- Modular Decomposition: Core logic is decoupled into specialized classes (e.g.,
Board,MoveValidator,Piece,MoveGenerator). This ensures that changing the evaluation logic does not affect the move generation integrity. - Encapsulation: The internal state of the board is managed safely, exposing only necessary APIs to the user while maintaining high performance.
- Extensibility: By utilizing interfaces and abstract base classes, developers can easily plug in new evaluation algorithms, search depths, or custom piece movement rules without restructuring the existing codebase.
This engine fully supports the standard laws of chess (FIDE rules), ensuring that every game state transition is valid and accurate.
- Advanced Move Generation: Optimized algorithms for generating pseudo-legal and legal moves.
- Special Rule Implementation:
- Castling: Complete support for King and Queen-side castling, including state validation for path clearance and check status.
- En Passant: Precision logic for handling pawn captures "in passing."
- Pawn Promotion: Full implementation of automated promotion to Queen, Rook, Bishop, or Knight.
- Game State Tracking: Manages castling rights, en passant potential, and draw conditions (including the fifty-move rule).
- Performance: Designed with a low memory footprint, focusing on high-speed execution suitable for recursive search trees.
- Language: C#
- Framework: .NET 8.0
- Design Pattern: Purely native .NET (Zero external dependencies).
- Compatibility: Cross-platform (Windows, Linux, macOS).
- Engine Initialization & Architecture Setup
- Core Move Generation & Validation
- Special Rule Implementation (Castling, En Passant, Promotion)
- UCI (Universal Chess Interface) Compatibility
- Real-time Multiplayer Integration (SignalR / TCP/IP)
To clone and run this repository locally:
git clone [https://github.com/Wexis39/ChessEngine.git](https://github.com/Wexis39/ChessEngine.git)
cd ChessEngine
dotnet build