Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8d82f7c
Add Doxygen docstring stubs to reach 80% coverage\n\nAdded brief @bri…
winapiadmin Jun 15, 2026
abad4c5
Use runtime BMI2 detection in magic lookup to prefer _pext_u64 when a…
winapiadmin Jun 15, 2026
62943a6
Revert runtime BMI2 detection in magic lookup (commit abad4c5)\n\nRev…
winapiadmin Jun 15, 2026
6b21a95
movegen: promotions count-only and sliding dispatch tidy
winapiadmin Jun 15, 2026
54e289e
Implement precomputed ray bitboards and optimize magic bitboard struc…
winapiadmin Jun 15, 2026
876ee5f
Apply automatic changes
winapiadmin Jun 15, 2026
b463471
idk, feature update, optimizations and gh actions bugfix maybe
winapiadmin Jun 15, 2026
8397b29
Apply automatic changes
winapiadmin Jun 15, 2026
c2f7eb1
📝 Add docstrings to `optimizations`
coderabbitai[bot] Jun 16, 2026
9eb5007
Apply automatic changes
coderabbitai[bot] Jun 16, 2026
4513cab
fixed IS_RELEASE, coderabbit docstring gen compile error, gh actions …
winapiadmin Jun 16, 2026
ed376ba
failure fix
winapiadmin Jun 16, 2026
69661f5
tiny nitpicks for generators (i use make/ninja btw)
winapiadmin Jun 16, 2026
90c3575
some optimization macros
winapiadmin Jun 16, 2026
e5c6309
apply format
winapiadmin Jun 16, 2026
a9e83c7
compile fix
winapiadmin Jun 16, 2026
7917d3f
compile fix
winapiadmin Jun 16, 2026
debd31e
Merge branch 'main' of https://github.com/winapiadmin/chesslib into d…
winapiadmin Jun 16, 2026
5f8801b
doxygen docgen bug (coderabbit artifact after failure)
winapiadmin Jun 16, 2026
e9a81ce
compile bug
winapiadmin Jun 16, 2026
f4bc3fc
clang-format bug
winapiadmin Jun 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
./** text=auto eol=lf
* text=auto eol=lf
64 changes: 32 additions & 32 deletions .github/workflows/doxygen.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
name: Doxygen docs
on:
push:
branches: [ main ]
jobs:
build-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
with:
persist-credentials: false
- name: Install dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -y doxygen graphviz
- name: Build docs
working-directory: ${{ github.workspace }}
run: |
if [ ! -f Doxyfile ]; then echo "Doxyfile not found in repo root"; exit 1; fi
doxygen Doxyfile
- name: Upload docs artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: doxygen-html
path: doc/html
retention-days: 7
name: Doxygen docs

on:
push:
branches: [ main ]

jobs:
build-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
with:
persist-credentials: false

- name: Install dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -y doxygen graphviz

- name: Build docs
working-directory: ${{ github.workspace }}
run: |
if [ ! -f Doxyfile ]; then echo "Doxyfile not found in repo root"; exit 1; fi
doxygen Doxyfile

- name: Upload docs artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: doxygen-html
path: doc/html
retention-days: 7
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
with:
ref: ${{ github.head_ref }}
persist-credentials: false
persist-credentials: true # commit
- name: Install clang-format
run: sudo apt-get update && sudo apt-get install -y clang-format

Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
!.github/**
!.github/
!Doxyfile
!doc/
# Ignore build/editor junk
build/
out/
Expand All @@ -21,4 +20,4 @@ out/
.cache/
cmake-*/
# Ignore asm outputs
*.s
*.s
40 changes: 20 additions & 20 deletions Doxyfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Doxyfile 1.9.1
PROJECT_NAME = "chesslib"
OUTPUT_DIRECTORY = doc
INPUT = .
RECURSIVE = YES
EXTRACT_ALL = YES
EXTRACT_PRIVATE = YES
GENERATE_HTML = YES
GENERATE_LATEX = NO
GENERATE_XML = YES
XML_OUTPUT = xml
QUIET = YES
GENERATE_TREEVIEW = YES
INLINE_SOURCES = YES
STRIP_FROM_PATH = "$(PWD)"
FILE_PATTERNS = *.h *.hpp *.cpp
EXCLUDE = build
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_AS_ERROR = YES
# Doxyfile 1.9.1
PROJECT_NAME = "chesslib"
OUTPUT_DIRECTORY = doc
INPUT = .
RECURSIVE = NO
EXTRACT_ALL = YES
EXTRACT_PRIVATE = YES
GENERATE_HTML = YES
GENERATE_LATEX = NO
GENERATE_XML = YES
XML_OUTPUT = xml
QUIET = YES
GENERATE_TREEVIEW = YES
INLINE_SOURCES = YES
STRIP_FROM_PATH = "$(PWD)"
FILE_PATTERNS = *.h *.hpp *.cpp
EXCLUDE = build
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_AS_ERROR = YES
12 changes: 6 additions & 6 deletions attacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,9 @@ _POSSIBLY_CONSTEXPR std::array<Bitboard, 0x19000> RookAttacks = rookData.second;
/**
* @brief Returns the attack bitboard for a bishop on the given square.
*
* @param sq The square where the bishop is located.
* @param occupied The occupied squares that block the bishop's attack paths.
* @return Bitboard with bits set for each square the bishop attacks.
* @param sq Bishop square.
* @param occupied Occupancy bitboard.
* @return Bitboard of squares attacked.
*/
[[nodiscard]] Bitboard bishop(Square sq, Bitboard occupied) {
const auto &entry = BishopTable[(int)sq];
Expand All @@ -337,9 +337,9 @@ _POSSIBLY_CONSTEXPR std::array<Bitboard, 0x19000> RookAttacks = rookData.second;

/**
* @brief Look up rook attacks from the precomputed magic table.
* @param sq The square where the rook is located.
* @param occupied A bitboard representing occupied squares.
* @return A bitboard of squares the rook can attack.
* @param sq Rook square.
* @param occupied Occupancy bitboard.
* @return Bitboard of squares attacked.
*/
[[nodiscard]] Bitboard rook(Square sq, Bitboard occupied) {
const auto &entry = RookTable[(int)sq];
Expand Down
8 changes: 1 addition & 7 deletions attacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,7 @@ template <Color c> [[nodiscard]] constexpr Bitboard pawn(const Bitboard pawns) {
/// @param sq Square.
/// @param occupied Occupancy bitboard.
/// @return Bitboard of squares attacked.
template <PieceType pt> /**
* Computes attack squares for a slider piece.
* @param sq Square the piece occupies.
* @param occupied Squares currently occupied on the board.
* @return Bitboard of squares attacked by the piece.
*/
[[nodiscard]] inline Bitboard slider(Square sq, Bitboard occupied) {
template <PieceType pt> [[nodiscard]] inline Bitboard slider(Square sq, Bitboard occupied) {
static_assert(pt == PieceType::BISHOP || pt == PieceType::ROOK || pt == PieceType::QUEEN, "PieceType must be a slider!");

if constexpr (pt == PieceType::BISHOP)
Expand Down
2 changes: 1 addition & 1 deletion fwd_decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ enum class ContiguousMappingPiece : uint8_t;
/// @brief Default chess position type (uses EnginePiece).
using Position = _Position<EnginePiece, void>;

/// @typedef Board
/// @brief Alias for Position.
/// @deprecated Use Position instead
using Board [[deprecated("Use Position instead")]] = Position;

} // namespace chess
26 changes: 15 additions & 11 deletions movegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,17 @@ inline Move *splat_moves(Move *moveList, Square from, Bitboard to_bb) {
}
#endif
} // namespace _chess

template <typename ListT> /**
* @brief Appends moves from a source square to destination squares, or counts them.
*
* For Movelist, generates and stores all moves efficiently. For CountOnlyList,
* only increments the count. For other list types, appends placeholder moves.
*
* @param from Source square for all moves.
* @param targets Bitboard of destination squares.
*/
inline void record_moves(ListT &list, Square from, Bitboard targets) {
/**
* @brief Appends moves from a source square to destination squares, or counts them.
*
* For Movelist, generates and stores all moves efficiently. For CountOnlyList,
* only increments the count. For other list types, appends placeholder moves.
*
* @param list The list of moves
* @param from Source square for all moves.
* @param targets Bitboard of destination squares.
*/
template <typename ListT> inline void record_moves(ListT &list, Square from, Bitboard targets) {
if constexpr (std::is_same_v<ListT, Movelist>) {
_chess::splat_moves(list.data() + list.size_, from, targets);
list.size_ += popcount(targets);
Expand Down Expand Up @@ -366,6 +366,8 @@ template <typename T, Color c, bool capturesOnly, typename ListT>
* Generates all knight moves subject to pin and check constraints.
* If `capturesOnly` is true, restricts to capture moves only.
*
* @param pos The position.
* @param list The move list to record moves into.
* @param _pin_mask Bitboard of pinned pieces; pinned knights are excluded.
* @param _check_mask Bitboard indicating squares that resolve checks.
*/
Expand Down Expand Up @@ -462,6 +464,8 @@ template <typename T, Color c, PieceType pt, bool capturesOnly, typename ListT>
* constraints and check restrictions. Pieces pinned along rook lines are confined to those lines;
* pieces pinned along bishop lines are confined to those diagonals.
*
* @param pos The position.
* @param moves The move list to record moves into.
* @param _rook_pin Bitboard of squares pinned along rook lines (vertical/horizontal).
* @param _bishop_pin Bitboard of squares pinned along bishop lines (diagonals).
* @param _check_mask Bitboard of legal destination squares when in check.
Expand Down
13 changes: 7 additions & 6 deletions movegen.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,27 @@
namespace chess::movegen {

/// @brief Generate en-passant captures for the given colour.
template <typename T, Color c, typename ListT> void genEP(const _Position<T, void> &, ListT &);
template <typename T, Color c, typename ListT> HOTFUNC void genEP(const _Position<T, void> &, ListT &);

/// @brief Generate double-pawn pushes (from the starting rank).
template <typename T, Color c, typename ListT> void genPawnDoubleMoves(const _Position<T, void> &, ListT &, Bitboard, Bitboard);
template <typename T, Color c, typename ListT>
HOTFUNC void genPawnDoubleMoves(const _Position<T, void> &, ListT &, Bitboard, Bitboard);

/// @brief Generate single-pawn moves (pushes and captures).
template <typename T, Color c, bool capturesOnly, typename ListT>
void genPawnSingleMoves(const _Position<T, void> &, ListT &, Bitboard, Bitboard, Bitboard);
HOTFUNC void genPawnSingleMoves(const _Position<T, void> &, ListT &, Bitboard, Bitboard, Bitboard);

/// @brief Generate knight moves.
template <typename T, Color c, bool capturesOnly, typename ListT>
void genKnightMoves(const _Position<T, void> &, ListT &, Bitboard, Bitboard);
HOTFUNC void genKnightMoves(const _Position<T, void> &, ListT &, Bitboard, Bitboard);

/// @brief Generate king moves.
template <typename T, Color c, bool capturesOnly, typename ListT>
void genKingMoves(const _Position<T, void> &, ListT &, Bitboard);
HOTFUNC void genKingMoves(const _Position<T, void> &, ListT &, Bitboard);

/// @brief Generate sliding-piece moves (bishop, rook, queen).
template <typename T, Color c, PieceType pt, bool capturesOnly, typename ListT>
void genSlidingMoves(const _Position<T, void> &, ListT &, Bitboard, Bitboard, Bitboard);
HOTFUNC void genSlidingMoves(const _Position<T, void> &, ListT &, Bitboard, Bitboard, Bitboard);

/// @brief Precomputed between-square bitboards.
/// @details squares_between_bb[sq1][sq2] contains a bitboard of all squares
Expand Down
Loading