Thank you for your interest in contributing to HydroChess! This guide explains the workflow for making changes to the engine.
← Back to README | Setup Guide | Engine Architecture | SPRT Testing | Roadmap
The contribution workflow has three stages:
- Implement - Write your feature or fix
- Test - Verify correctness with unit tests
- Validate - Run SPRT if the change affects playing strength
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ Implement │ --> │ Test │ --> │ SPRT │
│ Feature │ │ (cargo) │ │ (optional) │
└──────────────┘ └──────────────┘ └──────────────┘
| Change Type | Examples | Needs SPRT? |
|---|---|---|
| Bug fix | Crash fix, move generation error | Usually no |
| Refactor | Code cleanup, no behavior change | No |
| Search improvement | New pruning, better move ordering | Yes |
| Evaluation change | New eval term, tuned values | Yes |
| New feature | New variant, new piece type | Depends |
- Use
cargo fmtbefore committing - Run
cargo clippyto catch common issues - Write meaningful commit messages
# Format code
cargo fmt
# Check for issues
cargo clippy --libAll changes must pass the existing test suite.
# Run all library tests
cargo test --lib
# Run with output shown
cargo test --lib -- --nocapture
# Run a specific test module
cargo test search::tests --libPerft validates that move generation is correct:
cargo test --test perft# Generate coverage report
cargo llvm-cov --lib
# Aim for >80% line coverage on modified filesIf your change affects search or evaluation, you must run SPRT to prove it doesn't weaken the engine.
Run SPRT for:
- ✅ Search algorithm changes (LMR, pruning, extensions)
- ✅ Evaluation term additions or modifications
- ✅ Move ordering improvements
- ✅ Time management changes
Skip SPRT for:
- ❌ Bug fixes (already broken behavior)
- ❌ Code refactoring (no behavior change)
- ❌ Documentation updates
- ❌ Test additions
- Build your baseline (before changes):
# Save current state as "old" engine
wasm-pack build --target web --out-dir pkg-old- Make your changes and rebuild:
# This happens automatically when you run SPRT- Run the SPRT test:
cd sprt
npm run dev-
Open
http://localhost:3000and configure your test:- Use
allpreset for most changes - Mode:
Gainer(proving improvement) orNon-Regression(proving no regression)
- Use
-
Wait for result:
- ✅ PASSED: Your change is an improvement (or at least not worse)
- ❌ FAILED: Your change weakens the engine
⚠️ INCONCLUSIVE: Need more games or different bounds
See SPRT Documentation for full details.
Before submitting a PR, verify:
- Code compiles without warnings (
cargo build --lib) - All tests pass (
cargo test --lib) - Code is formatted (
cargo fmt) - Clippy is happy (
cargo clippy --lib) - Logic changes have SPRT results (if applicable)
- New code has test coverage
Understanding the codebase:
| Module | Purpose |
|---|---|
lib.rs |
WASM bindings, Engine struct |
board.rs |
Piece types, coordinates, board representation |
game.rs |
GameState, make/undo moves, repetition detection |
moves.rs |
Legal move generation for all pieces |
| Module | Purpose |
|---|---|
search.rs |
Main iterative deepening + alpha-beta |
search/tt.rs |
Transposition table |
search/ordering.rs |
Move ordering heuristics |
search/see.rs |
Static exchange evaluation |
| Module | Purpose |
|---|---|
evaluation/base.rs |
Core evaluation + piece-square logic |
evaluation/mop_up.rs |
Endgame evaluation for mating |
evaluation/insufficient_material.rs |
Draw detection |
evaluation/variants/*.rs |
Variant-specific evaluation |
| Module | Purpose |
|---|---|
src/bin/*.rs |
Standalone tools: Helpmate solver, SPSA tuner, debuggers (see src/bin/README.md) |
- Add the term in
src/evaluation/base.rs - Add tests to verify the term works correctly
- Run SPRT to validate it improves play
- Add the piece to
src/board.rs(PieceTypeenum) - Add move generation in
src/moves.rs - Add evaluation in
src/evaluation/base.rs - Add tests for move generation and evaluation
Use SPSA for automatic parameter tuning:
cd sprt
npm run spsa -- --games 60 --iterations 100See SPSA Documentation.
- Check existing tests for examples
- Review similar code in the codebase
- Open an issue for questions