βοΈ Java Chess Move Generator (Magic Bitboards) A high-performance chess move generator written in Java, utilizing magic bitboards, bitshifting, and precomputed magic numbers to efficiently generate legal moves, especially for sliding pieces like rooks, bishops, and queens.
π Key Features
β‘ Fast move generation using 64-bit long bitboards
π§ Magic bitboards for constant-time rook and bishop attack generation
π§ Bitwise operations and shifting for optimal performance
π Modular, clean Java architecture ready for engine integration
β Legal move filtering β ensures moves donβt leave the king in check
π§ͺ Perft testing framework β verifies move correctness via node counting
π UCI move serialization β outputs standard strings like e2e4, e7e8q
π§ͺ Six JUnit tests featuring complex, bug-catching positions to ensure accuracy and robustness
π€ Suitable for integration into chess engines and AI
π What Are Magic Bitboards? Magic Bitboards are a technique to speed up attack generation for sliding pieces. Instead of scanning all directions manually, this method:
Masks relevant squares around a piece.
Multiplies the occupancy by a special "magic number".
Shifts the result to generate a unique index.
Uses that index to look up a precomputed attack bitboard.
This enables near-constant time move generation with no loops.
π
β Pawns (non-magic, bitwise forward capture/generate)
β Knights (bitmask lookups)
β Kings (bitmask lookups)
β Bishops (magic bitboards)
β Rooks (magic bitboards)
β Queens (combo of rook + bishop)
β‘ Performance
Rook/Bishop/Queen moves in O(1) time
π License MIT License β free to use, modify, and distribute.