rudzen / ChessLib

C# chess library containing a complete data structure and move generation.
MIT License
81 stars 23 forks source link
bitboard bitboard-datastructure bitboard-hash bitboards c-sharp chess chess-library chessboard chesslib dotnet fen magic-bitboards move-generator netcore perft perftest timer-clock transposition-table zobrist zobrist-hashing

ChessLib

A C# chess data library with complete move generation and all needed custom types.

Build status Build & Test Nuget

Requirements

What is this for?

This library contains all the data, types and structures for which to create a piece of chess software. It does not contain any heuristics or search algorithms as these are meant to be implemented separately.

It also contains KPK bit compact data to determine endgame draw.

Can I use this as a starting point for my chess software?

Yes you can, it is designed with that in mind.

Features

Perft

Perft console test program approximate timings to depth 6 for normal start position

Transposition Table

ph

Move Generator

Example

// generate all legal moves for current position
const string fen = "rnbqkbnr/1ppQpppp/p2p4/8/8/2P5/PP1PPPPP/RNB1KBNR b KQkq - 1 6";

var game = GameFactory.Create(fen);
var moveList = game.Pos.GenerateMoves();
// ..

MoveList example

By using the MoveListPool you can avoid allocations and reuse the same MoveList instance.

var moveList = _moveListPool.Get();
moveList.Generate(position, MoveType.Legal);
var moves = moveList.Get();

foreach (var move in moves)
{
    // do something
}

_moveListPool.Return(moveList);

What is not included?

Planned