Code Monkey home page Code Monkey logo

chesssharp's Introduction

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

chesssharp's People

Contributors

gregstanley avatar

Stargazers

R. Abächerli avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.