1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
Laura-Core: a fast and efficient move generator for chess engines.
Copyright (C) 2024-2025 HansTibberio <hanstiberio@proton.me>
Laura-Core is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Laura-Core is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Laura-Core. If not, see <https://www.gnu.org/licenses/>.
*/
use crate::;
// Includes the pre-generated files containing the slider attack bitboards and black magic numbers.
// These files are created at build time and are dynamically included at compile-time into the current
// Rust module.
include!;
include!;
include!;
/// The shift constant used for rook magic numbers. This value is used to compute the final index for
/// a given square, based on its blockers and magic number.
const ROOK_SHIFT: usize = 12;
/// The shift constant used for bishop magic numbers.
const BISHOP_SHIFT: usize = 9;
/// Struct representing a single black magic entry for a slider piece (rook or bishop).
///
/// This entry is used in combination with a blocker bitboard to quickly compute valid attacks for the slider.
/// Calculates the index of a slider piece's attack bitboard based on the given blockers and magic number.
/// Gets the attack bitboard for a rook from a given square, considering the positions of blockers.
///
/// This function uses the magic number technique to quickly compute the valid attack squares for a rook.
/// The precomputed magic numbers for rooks are used to generate the attack bitboard for the given square,
/// considering the positions of blockers (other pieces on the board).
/// Gets the attack bitboard for a bishop from a given square, considering the positions of blockers.
///
/// This function follows the same approach as `get_rook_attacks`, but is designed for bishop attacks.
/// It uses the magic number technique to quickly compute the valid attack squares for a bishop,
/// considering the positions of blockers (other pieces on the board).