GitHub·· 8 天前AI 评分22
Apeiron:面向 Infinite Chess 的 Rust/WebAssembly 国际象棋引擎
FirePlank/infinite-chess-engine
AI 导读
Apeiron 是一个用 Rust 编写并编译为 WebAssembly 的国际象棋引擎,专为 Infinite Chess 设计,支持任意尺寸棋盘的坐标制系统。
正文
Apeiron
A Rust chess engine compiled to WebAssembly, designed for Infinite Chess.
Elo Gain Over Time
Documentation
| Document | Description |
|---|---|
| Setup Guide | Installation and build instructions |
| Contributing Guide | Workflow for development and testing |
| Engine Architecture | Deep dive into engine design and logic |
| SPRT Testing | Strength validation tools |
| Utility Binaries | Solvers, debuggers, and tuning scripts |
| Roadmap | Current status and planned features |
Features
- Infinite Board: Coordinate-based system supporting arbitrary board sizes.
- 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.) plus a small quantized net that corrects it from the HCE's own terms.
- Performance: Written in Rust with support for Lazy SMP multithreading.
- Variants & Fairy Pieces: Support for all fairy pieces and unique infinite chess variants.
Quick Start
# 1. Install Rust and wasm-pack (see docs/SETUP.md for details) cargo install wasm-pack # 2. Build for browser (Multi-threaded / Lazy SMP is the default) wasm-pack build --target web --release # 3. Build a single-threaded engine instead wasm-pack build --target web --release --no-default-features # 4. Output is in pkg/
For detailed setup instructions, see docs/SETUP.md.
Usage
JavaScript API
import init, { Engine } from './pkg/apeiron.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, // Site level 1..8; level 8 is full strength 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 legal moves const moves = engine.get_legal_moves_js();
Multithreaded Search
To use parallel search, you must initialize the WASM module's thread pool:
import init, { Engine, initThreadPool } from './pkg/apeiron.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 unit tests cargo test --lib # Run perft tests cargo test --test perft
For strength testing, see sprt/README.md.
License
This project is licensed under the GNU General Public License v3.0 - see LICENSE for details.
Links
- Infinite Chess - Play infinite chess online
- Chess Programming Wiki - Engine development resources
- Stockfish - The world's strongest open-source chess engine
来源:GitHub · github.com