Skip to content

Implement magic bitboards for sliding piece move generation#1

Open
sbesselsen wants to merge 1 commit into
mainfrom
claude/magic-bitboards-83OMX
Open

Implement magic bitboards for sliding piece move generation#1
sbesselsen wants to merge 1 commit into
mainfrom
claude/magic-bitboards-83OMX

Conversation

@sbesselsen

Copy link
Copy Markdown
Owner

Replace the manual ray-casting implementation for rooks, bishops, and queens
with O(1) magic bitboard lookups. This uses precomputed lookup tables indexed
by a "magic" hash of the occupancy on relevant squares, similar to Stockfish's
approach.

Key changes:

  • Add magic.rs module with lazy-initialized lookup tables using OnceLock
  • Use proven magic numbers from Stockfish for both rooks and bishops
  • Simplify rooklike_moves_masks and bishoplike_moves_masks in board.rs
  • Handle board's inverted bit indexing at the interface

All perft tests pass with correct results.

Replace the manual ray-casting implementation for rooks, bishops, and queens
with O(1) magic bitboard lookups. This uses precomputed lookup tables indexed
by a "magic" hash of the occupancy on relevant squares, similar to Stockfish's
approach.

Key changes:
- Add magic.rs module with lazy-initialized lookup tables using OnceLock
- Use proven magic numbers from Stockfish for both rooks and bishops
- Simplify rooklike_moves_masks and bishoplike_moves_masks in board.rs
- Handle board's inverted bit indexing at the interface

All perft tests pass with correct results.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants