Skip to content

A chess engine made for the infinitechess.org website that can play on an unbounded plain.

License

Notifications You must be signed in to change notification settings

FirePlank/infinite-chess-engine

Repository files navigation

HydroChess WASM

A high-performance Rust chess engine compiled to WebAssembly, designed for Infinite Chess.

License: GPL-3.0

📚 Documentation

Document Description
Setup Guide Install Rust, wasm-pack, and build the engine
Contributing Guide Workflow for adding features and testing changes
SPRT Testing Run strength tests to validate engine changes
Roadmap Planned features, technical debt, and backlog
Utility Binaries Solvers, debuggers, and tuning tools

✨ Features

  • Infinite Architecture: Coordinate-based board supporting arbitrary world sizes and non-standard geometries.
  • Advanced Search: Iterative deepening PVS with Aspiration Windows, Null Move Pruning, LMR, history-based move ordering, and more.
  • Evaluation: Modular HCE (Material, Cloud Centrality, Pawn Advancement, King Safety, etc.) with experimental NNUE support.
  • Scalable Performance: High-performance Rust core with Lazy SMP multithreading.
  • Variants & Fairy Pieces: Full support for all fairy pieces and unique infinite chess variants.

🚀 Quick Start

# 1. Install Rust and wasm-pack (see docs/SETUP.md for details)
rustup target add wasm32-unknown-unknown
cargo install wasm-pack

# 2. Build for browser (Single-threaded)
wasm-pack build --target web

# 3. Build for browser (Multi-threaded)
node build_mt.js

# 4. Output is in pkg/ - ready for use with your bundler

For detailed setup instructions, see docs/SETUP.md.


📖 Usage

JavaScript API

import init, { Engine } from './pkg/hydrochess_wasm.js';

await init();

// Initialize engine from ICN string
const icnString = "w 0/100 1 (8|1) P1,2+|P2,2+|P3,2+|P4,2+|P5,2+|P6,2+|P7,2+|P8,2+|...|K5,1+|k5,8+";
const engineConfig = {
    strength_level: 3, // 1=Easy, 2=Medium, 3=Hard (default)
    wtime: 60000,      // White clock in ms
    btime: 60000,      // Black clock in ms
    winc: 1000,        // White increment in ms
    binc: 1000         // Black increment in ms
};

const engine = Engine.from_icn(icnString, engineConfig);

// Get best move
const result = engine.get_best_move();
// Example result: { from: "1,2", to: "1,4", promotion: null, eval: 34, depth: 12 }

// Get best move with time limit (milliseconds)
const result = engine.get_best_move_with_time(500);

// Get all legal moves
const moves = engine.get_legal_moves_js();

Multithreaded usage

To use parallel search, you must initialize the WASM module's thread pool:

import init, { Engine, initThreadPool } from './pkg/hydrochess_wasm.js';

await init();
await initThreadPool(navigator.hardwareConcurrency);

const engine = Engine.from_icn(icnString, engineConfig);
const result = engine.get_best_move(); // Now uses all available cores

Note

Parallel WASM requires specific HTTP headers (Cross-Origin-Opener-Policy: same-origin and Cross-Origin-Embedder-Policy: require-corp) to be served by your web server.


🧪 Testing

# Run all unit tests
cargo test --lib

# Run with coverage
cargo llvm-cov --lib

# Run perft tests (move generation validation)
cargo test --test perft

For testing engine strength changes, see sprt/README.md.


📄 License

This project is licensed under the GNU General Public License v3.0 - see LICENSE for details.

🔗 Links

About

A chess engine made for the infinitechess.org website that can play on an unbounded plain.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •