#move-gen #chess-engine #fast #chess

bunnies

A fast chess library for chess engines

6 releases (breaking)

Uses new Rust 2024

new 0.5.0 May 1, 2025
0.4.1 Apr 28, 2025
0.3.0 Apr 15, 2025
0.2.0 Mar 27, 2025
0.1.0 Mar 11, 2025

#474 in Math

Download history 72/week @ 2025-03-05 42/week @ 2025-03-12 129/week @ 2025-03-26 5/week @ 2025-04-02 34/week @ 2025-04-09 77/week @ 2025-04-16 190/week @ 2025-04-23

315 downloads per month

MIT license

265KB
6K SLoC

bunnies

Crates.io

A fast chess library for chess engines. Currently in alpha.

Current Features

  • Game state representation
  • Legal move generation
  • Forwards-backwards move application
  • FEN parsing and generation
  • UCI generation
  • Full PGN parsing and generation
    • Support for NAGs and variations (comments are parsed, but not generated)
    • Support for nested variations
  • Perft tests
  • Game termination detection (and draw detection)

Optimizations

bunnies makes use of the following optimizations:

  • Bitboard-based board representation
  • Direct legal move generation that takes pins and checks into account (no pseudolegal step and validation)
  • Make-unmake move application (eliminating the need to copy game state during search)
  • Magic bitboards for sliding piece attack generation
  • Precomputed attacks for knights and kings
  • Zobrist hashing for board state hashing

bunnies is currently able to generate ~23M moves/thread/second (as measured on an M1 Macbook Pro), which is not nearly as fast as programs like Stockfish (which is able to generate ~120M moves/thread/sec under the same conditions).

Contribution

bunnies needs the following to make 1.0.0 happen:

  • Multithreading
  • Further performance improvement
    • Figure out bottlenecks
    • Solve inefficiencies
  • More tests wouldn't hurt
  • More benchmarks wouldn't hurt
  • Support for PGN comments

Feedback and contributions welcome!

Dependencies

~8.5MB
~128K SLoC