pax.uciChessEngine 0.7.1

dotnet add package pax.uciChessEngine --version 0.7.1
                    
NuGet\Install-Package pax.uciChessEngine -Version 0.7.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="pax.uciChessEngine" Version="0.7.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="pax.uciChessEngine" Version="0.7.1" />
                    
Directory.Packages.props
<PackageReference Include="pax.uciChessEngine" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add pax.uciChessEngine --version 0.7.1
                    
#r "nuget: pax.uciChessEngine, 0.7.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package pax.uciChessEngine@0.7.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=pax.uciChessEngine&version=0.7.1
                    
Install as a Cake Addin
#tool nuget:?package=pax.uciChessEngine&version=0.7.1
                    
Install as a Cake Tool

Introduction

C# dotnet Universal Chess Interface wrapper for interacting with chess engine processes.

Getting started

Installation

You can install it with the Package Manager in your IDE or alternatively using the command line:

dotnet add package pax.uciChessEngine

Usage

The library now exposes a UciEngine that talks to a UCI-compatible binary and a small pooling helper in pax.uciChessEngine.EngineServices for safe reuse.

Quick start (single engine)

using pax.uciChessEngine;

await using var engine = new UciEngine(@"path\to\engine.binary");
await engine.StartAsync();
await engine.SetOption("Threads", 4);
await engine.SendAsync("ucinewgame", CancellationToken.None);
var bestMove = await engine.GetBestMoveAsync("1r1qr2k/p1n2p2/b1np1Np1/2p5/8/2NPB1PP/Pb1Q2B1/4RRK1 w - - 2 21", TimeSpan.FromSeconds(2));
Console.WriteLine($"Best move: {bestMove}");

Pooled usage (multiple consumers)

using pax.uciChessEngine;
using pax.uciChessEngine.EngineServices;

var options = new EngineRunOptions
{
    BinaryPath = @"path\to\engine.exe",
    PoolSize = 2,
    Threads = 4,
    Pvs = 2,
    HashMb = 256
};

var provider = EngineService.GetEngineSessionProvider(options);

await using var lease = await provider.AcquireAsync(CancellationToken.None);
var evals = await lease.Session.UseAsync(
    engine => EngineService.GetEvaluation(
        fen: "startpos",
        sideToMove: pax.chess.PieceColor.White,
        thinkTime: TimeSpan.FromMilliseconds(300),
        engine: engine,
        token: CancellationToken.None),
    CancellationToken.None);

Console.WriteLine($"Depth: {evals[0].Depth}, Score: {evals[0].Score}");

Migration from v0.6.* to v0.7

v0.7 is a breaking API refresh and targets .NET 10. Projects using v0.6.* on .NET 8 should update their target framework before upgrading the package.

The old Engine type has been replaced by UciEngine:

// v0.6.*
using var engine = new Engine("Stockfish", @"path\to\engine.exe");
await engine.Start();
await engine.IsReady();
await engine.SetOption("Threads", 4);
await engine.Send("ucinewgame");
await engine.Send("go");
await Task.Delay(2000);
await engine.Send("stop");
var info = engine.GetInfo();
// v0.7
await using var engine = new UciEngine(@"path\to\engine.exe");
await engine.StartAsync();
await engine.SetOption("Threads", 4);
var bestMove = await engine.GetBestMoveAsync(
    "1r1qr2k/p1n2p2/b1np1Np1/2p5/8/2NPB1PP/Pb1Q2B1/4RRK1 w - - 2 21",
    TimeSpan.FromSeconds(2));

Main changes:

  • Replace Engine with UciEngine; the engine name constructor argument and LogLevel overload are no longer part of the public entry point.
  • Use async lifecycle methods: StartAsync, SendAsync, StopAsync, and await using/DisposeAsync.
  • StartAsync performs the UCI handshake, so callers usually do not need separate GetOptions() or IsReady() calls.
  • Read engine options from engine.Status.EngineOptions instead of Status.Options.
  • Read engine state from engine.Status.EngineState instead of Status.State.
  • BestMove and Ponder are now UCI move strings (string?) instead of EngineMove values.
  • For one-shot searches, prefer GetBestMoveAsync(fen, thinkTime, token) instead of manually sending position, go, waiting, and sending stop.
  • For repeated analysis or concurrent consumers, use pax.uciChessEngine.EngineServices.EngineService.GetEngineSessionProvider(...) with EngineRunOptions so engine processes are reused instead of repeatedly started and disposed.

Sample Project pax.BlazorChess

ChangeLog

<details open="open"><summary>v0.7.0</summary>

  • ** Breaking Changes **
  • Update to dotnet 10
  • UciEngine usability refreshed with async API.
  • Engine pooling

</details>

<details><summary>v0.6.1</summary>

  • ** Breaking Changes **
  • Update to dotnet 8
  • Logging disabled by default. Enable it with: Engine engine = new Engine("EngineName", @"path\to\engine\binary", LogLevel.Warning);

</details>

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.7.1 129 6/8/2026
0.7.0 121 6/8/2026
0.6.3 393 3/16/2025
0.6.2 1,309 1/25/2022
0.6.1 1,113 1/23/2022
0.6.0 1,139 1/20/2022
0.5.5 1,136 1/16/2022
0.5.4 1,111 1/13/2022
0.5.3 951 1/9/2022
0.5.2 978 1/6/2022