Skip to content

Commit

Permalink
eliminate ray table
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf committed Aug 7, 2024
1 parent 20592a1 commit a12295b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/attacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,20 @@ pub fn attacks(sq: Square, piece: Piece, occupied: Bitboard) -> Bitboard {
/// ```
#[inline]
pub fn ray(a: Square, b: Square) -> Bitboard {
Bitboard(RAYS[usize::from(a)][usize::from(b)])
if a == b {
Bitboard::EMPTY
} else if a.rank() == b.rank() {
Bitboard::from_rank(a.rank())
} else if a.file() == b.file() {
Bitboard::from_file(a.file())
} else if Bitboard(DIAG_RANGE[usize::from(a)]).contains(b) {
Bitboard(DIAG_RANGE[usize::from(a)]).with(a)
} else if Bitboard(ANTI_DIAG_RANGE[usize::from(a)]).contains(b) {
Bitboard(ANTI_DIAG_RANGE[usize::from(a)]).with(a)
} else {
Bitboard::EMPTY
}
//Bitboard(RAYS[usize::from(a)][usize::from(b)])
}

/// The squares between the two squares (bounds not included), or an empty
Expand Down

0 comments on commit a12295b

Please sign in to comment.