Skip to content

gregstanley/ChessSharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChessSharp

ChessSharp is a basic C# based Chess game (note game not engine as the UCI compatible component is just bare bones at the moment). It started as a little experiment when my son took an interest in Chess and then grew rapidly as I started to research how 'real' Chess programs worked. While experimenting it became clear that programming Chess is an art in it's own right and uses skills from all aspects of the discipline. The many years of academic research in the area has led to many advanced solutions to problems you don't even realise you have when you start but fortunately there is a lot of guidance out there to help. That said, I found many of the examples I encountered hard to get to grips with due to their highly optimised implementations. I also have a general interest in making sure any code I produce not only does the job but is also as simple and easy to access as possible and techniques so I set myself the goal of trying to produce a project to demonstrate:

  • Appropriate use of the latest C# syntax and general best practise thinking.
  • Simple implementations of core Chess programming concepts. While trying to keep a reasonable level of performance (this code is not intended to beat Stockfish but it turns out searching to ply 7 is harder than I initially thought). On my development machine the code searches about 500k nodes per second (and depending on your background that performance may seem extremely fast or extremely slow :-)).

C# and programming techniques summary

Chess programming specific feature summary

In progress

  • UCI compatible component.

What's missing

  • Quiescence search
  • 'Match drawn' detection within search. The game will detect a draw one a move has been played, it does not however detect draws during the search i.e. it just burns time investigating positions that are already drawn.

Getting Started

Clone the project to your local machine and launch in your IDE.

Source (src) projects:

  • ChessSharp Perft - Executable to test the perfromance of the move generation logic.
  • ChessSharp UCI Engine - Executable UCI engine.
  • ChessSharp UI - WPF based user interface for playing games of Chess (I'm not that familiar with WPF so I'm sure there's plenty of scope for improvement here).
  • ChessSharp.Common - Core types and data structures.
  • ChessSharp.Engine - All logic that is not directly move generation related.
  • ChessSharp.MoveGeneration - Legal move generation.
  • UCI Explorer - Console application to load UCI engines.

Test (tests) projects:

  • ChessSharp Tests - xUnit

Running the tests

These are xUnit based tests so you may need to install xUnit to run them.

Test cases

Mate in two: Fen: 8/6K1/1p1B1RB1/8/2Q5/2n1kP1N/3b4/4n3 w - - 0 1

  • Bd6a3
  • e4#

More: https://sites.google.com/site/darktemplarchess/mate-in-2-puzzles

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Acknowledgments

Resources

Known issues

  • Doesn't show final move in on Checkmate

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages