Water is a comprehensive chess suite designed to empower users in creating chess engines. Built using Zig, it features an iterative search engine with advanced techniques like Alpha-Beta Pruning and neural network integration. With an easy-to-use core library and UCI management, assembling a chess engine has never been simpler.
Water is a comprehensive chess library and engine developed in Zig, aimed at providing a robust platform for creating performance-driven chess engines. With a focus on architecture and ease of use, Water includes both a core library and a UCI (Universal Chess Interface) management system, facilitating the development of sophisticated chess applications.
Project Goals
Water is designed with several key objectives:
- To implement an iterative search engine that incorporates advanced strategies such as Alpha-Beta Pruning and Quiescence search.
- To develop a neural network-powered engine that utilizes NNUE (Efficiently Updatable Neural Networks) for enhanced gameplay.
Quick Start
Building Water is straightforward. Utilize the command:
zig build run --release
The engine operates via the UCI protocol, with more details available here.
Build Tools Requirements
To ensure compatibility and functionality, the following tools are essential:
- Zig 0.15.2: Other versions may encounter issues due to breaking changes.
- cloc: An optional tool for counting lines of code.
Core Build Commands
Water supports a variety of commands for building and testing:
| Command | Description |
|---|---|
build | Compile Water. Use --release for optimized build. |
run | Compile and execute Water. --release for optimization. |
perft | Execute the perft suite for performance testing; recommended to use with --release. |
bench | Run the performance benchmarking suite with suggested --release option. |
search | Execute search benchmarks, also utilizing --release for effectiveness. |
package | Generate the engine executable in ReleaseFast mode. |
test | Run all unit tests to ensure integrity. |
lint | Format verification for all source files, excluding build files. |
fmt | Format all source code not part of the build system. |
cloc | Count lines of Zig code using cloc. |
docs | Generate documentation for the library using Zig's docgen tool. |
Adding Water to Other Projects
To integrate Water as a dependency, execute:
zig fetch --save git+https://github.com/trevorswan11/water
Then, modify your build.zig to include Water as a module:
const exe = b.addExecutable(.{
.name = "foo",
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{
.name = "water",
.module = b.dependency("water", .{}).module("water"),
},
},
}),
});
To validate the installation, try the following in main.zig:
const std = @import("std");
const water = @import("water");
pub fn main() !void {
const allocator = std.heap.page_allocator;
var board = try water.Board.init(allocator, .{});
defer board.deinit();
const diagram = try water.uci.uciBoardDiagram(board, .{});
defer allocator.free(diagram);
std.debug.print("{s}", .{diagram});
}
Community Contributions
Contributions are welcomed to enhance and improve the library. For guidelines on contributing, please refer to CONTRIBUTING.md.
Acknowledgments
Water's development has been inspired by numerous projects and resources, including:
- The chess-library and its codebase,
- zigMemMapper for memory handling,
- Chess Programming Wiki's resources on NNUE,
- The Avalanche chess engine for architecture ideas,
- The pawnocchio engine's perft test suite,
- The legendary Stockfish engine for invaluable insights during development.
No comments yet.
Sign in to be the first to comment.