Skip to content

Commit 4b97573

Browse files
authored
Separating pure attacks from lookups (#67)
* updated clang tidy * renamed and moved some files around to respect lookups & attacks layout * fixed wrong naming
1 parent 1b87124 commit 4b97573

29 files changed

+737
-548
lines changed

.clang-tidy

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ WarningsAsErrors: "*"
99

1010
CheckOptions:
1111
- key: readability-identifier-length.IgnoredVariableNames
12-
value: "^[A-H][1-8]$|^to$"
12+
value: "^(sq|to|from|bb|A[1-8]|B[1-8]|C[1-8]|D[1-8]|E[1-8]|F[1-8]|G[1-8]|H[1-8])$"
1313
- key: readability-identifier-length.IgnoredParameterNames
14-
value: "^to$"
14+
value: "^(sq|to|from|bb)$"
15+
- key: readability-identifier-length.IgnoredLoopCounterNames
16+
value: "^(r|f)$"
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#pragma once
2+
3+
#include <bitbishop/bitboard.hpp>
4+
#include <bitbishop/square.hpp>
5+
6+
/**
7+
* @brief Computes bishop attacks along the northeast diagonal.
8+
*
9+
* Returns all squares reachable by a bishop moving northeast from the given
10+
* square, stopping at the first occupied square (inclusive).
11+
*
12+
* This function is occupancy-dependent and intended for runtime move generation.
13+
*
14+
* @param from The starting square
15+
* @param occupied Bitboard of all occupied squares on the board
16+
* @return Bitboard of attacked squares along the northeast diagonal
17+
*/
18+
Bitboard bishop_north_east_attacks(Square from, const Bitboard& occupied);
19+
20+
/**
21+
* @brief Computes bishop attacks along the northwest diagonal.
22+
*
23+
* Returns all squares reachable by a bishop moving northwest from the given
24+
* square, stopping at the first occupied square (inclusive).
25+
*
26+
* @param from The starting square
27+
* @param occupied Bitboard of all occupied squares on the board
28+
* @return Bitboard of attacked squares along the northwest diagonal
29+
*/
30+
Bitboard bishop_north_west_attacks(Square from, const Bitboard& occupied);
31+
32+
/**
33+
* @brief Computes bishop attacks along the southeast diagonal.
34+
*
35+
* Returns all squares reachable by a bishop moving southeast from the given
36+
* square, stopping at the first occupied square (inclusive).
37+
*
38+
* @param from The starting square
39+
* @param occupied Bitboard of all occupied squares on the board
40+
* @return Bitboard of attacked squares along the southeast diagonal
41+
*/
42+
Bitboard bishop_south_east_attacks(Square from, const Bitboard& occupied);
43+
44+
/**
45+
* @brief Computes bishop attacks along the southwest diagonal.
46+
*
47+
* Returns all squares reachable by a bishop moving southwest from the given
48+
* square, stopping at the first occupied square (inclusive).
49+
*
50+
* @param from The starting square
51+
* @param occupied Bitboard of all occupied squares on the board
52+
* @return Bitboard of attacked squares along the southwest diagonal
53+
*/
54+
Bitboard bishop_south_west_attacks(Square from, const Bitboard& occupied);
55+
56+
/**
57+
* @brief Computes all bishop attacks from a square, given board occupancy.
58+
*
59+
* Combines the four diagonal attack directions (NE, NW, SE, SW) and returns
60+
* the full set of squares attacked by a bishop on the given square.
61+
*
62+
* This function performs no legality filtering (pins, check, own pieces)
63+
* and is intended as a low-level attack generator for higher-level move logic.
64+
*
65+
* @param from The starting square
66+
* @param occupied Bitboard of all occupied squares on the board
67+
* @return Bitboard of all squares attacked by the bishop
68+
*/
69+
Bitboard bishop_attacks(Square from, const Bitboard& occupied);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#pragma once
2+
3+
#include <bitbishop/bitboard.hpp>
4+
#include <bitbishop/square.hpp>
5+
6+
/**
7+
* @brief Computes all queen attacks from a square, given board occupancy.
8+
*
9+
* Returns the union of rook-like (horizontal and vertical) and bishop-like
10+
* (diagonal) attacks reachable by a queen from the given square, stopping
11+
* at the first blocker in each direction (inclusive).
12+
*
13+
* This function is occupancy-dependent and performs no legality filtering:
14+
* it does not account for piece color, pins, check, or king safety.
15+
*
16+
* Intended as a low-level attack generator for:
17+
* - legal move generation
18+
* - check detection
19+
* - pin detection
20+
* - attack maps
21+
*
22+
* @param from The starting square
23+
* @param occupied Bitboard of all occupied squares on the board
24+
* @return Bitboard of all squares attacked by the queen
25+
*/
26+
Bitboard queen_attacks(Square from, const Bitboard& occupied);
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#pragma once
2+
3+
#include <bitbishop/bitboard.hpp>
4+
#include <bitbishop/square.hpp>
5+
6+
/**
7+
* @brief Computes rook attacks along the north direction.
8+
*
9+
* Returns all squares reachable by a rook moving north from the given square,
10+
* stopping at the first occupied square (inclusive).
11+
*
12+
* This function is occupancy-dependent and intended for runtime move generation.
13+
*
14+
* @param from The starting square
15+
* @param occupied Bitboard of all occupied squares on the board
16+
* @return Bitboard of attacked squares along the north direction
17+
*/
18+
Bitboard rook_north_attacks(Square from, const Bitboard& occupied);
19+
20+
/**
21+
* @brief Computes rook attacks along the south direction.
22+
*
23+
* Returns all squares reachable by a rook moving south from the given square,
24+
* stopping at the first occupied square (inclusive).
25+
*
26+
* @param from The starting square
27+
* @param occupied Bitboard of all occupied squares on the board
28+
* @return Bitboard of attacked squares along the south direction
29+
*/
30+
Bitboard rook_south_attacks(Square from, const Bitboard& occupied);
31+
32+
/**
33+
* @brief Computes rook attacks along the east direction.
34+
*
35+
* Returns all squares reachable by a rook moving east from the given square,
36+
* stopping at the first occupied square (inclusive).
37+
*
38+
* @param from The starting square
39+
* @param occupied Bitboard of all occupied squares on the board
40+
* @return Bitboard of attacked squares along the east direction
41+
*/
42+
Bitboard rook_east_attacks(Square from, const Bitboard& occupied);
43+
44+
/**
45+
* @brief Computes rook attacks along the west direction.
46+
*
47+
* Returns all squares reachable by a rook moving west from the given square,
48+
* stopping at the first occupied square (inclusive).
49+
*
50+
* @param from The starting square
51+
* @param occupied Bitboard of all occupied squares on the board
52+
* @return Bitboard of attacked squares along the west direction
53+
*/
54+
Bitboard rook_west_attacks(Square from, const Bitboard& occupied);
55+
56+
/**
57+
* @brief Computes all rook attacks from a square, given board occupancy.
58+
*
59+
* Combines the four orthogonal attack directions (north, south, east, west)
60+
* and returns the full set of squares attacked by a rook on the given square.
61+
*
62+
* This function is occupancy-dependent and performs no legality filtering:
63+
* it does not account for piece color, pins, check, or king safety.
64+
*
65+
* Intended as a low-level attack generator for:
66+
* - legal move generation
67+
* - check detection
68+
* - pin detection
69+
* - attack maps
70+
*
71+
* @param from The starting square
72+
* @param occupied Bitboard of all occupied squares on the board
73+
* @return Bitboard of all squares attacked by the rook
74+
*/
75+
Bitboard rook_attacks(Square from, const Bitboard& occupied);

0 commit comments

Comments
 (0)