Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
5c7a688
Delete .gitmodules
winapiadmin Feb 24, 2026
2c24054
Add square mirror and flip functions, replace ASSUME with assert
winapiadmin Feb 24, 2026
edb8d35
Replace HeapAllocatedValueList with preallocated std::vector
winapiadmin Feb 24, 2026
a75bb59
Update position.h
winapiadmin Feb 24, 2026
27740a2
Delete repetition.h
winapiadmin Feb 24, 2026
9679bc6
Remove coverage reporting configuration
winapiadmin Feb 24, 2026
51dae1f
Update types.h
winapiadmin Feb 24, 2026
9731a31
Update fwd_decl.h
winapiadmin Feb 24, 2026
ad19011
Update position.h
winapiadmin Feb 24, 2026
d4624ff
Refactor chess namespace and include forward declarations
winapiadmin Feb 24, 2026
36f74bb
Refactor is_zeroing and at functions in position.h
winapiadmin Feb 24, 2026
f63701d
Update position.cpp
winapiadmin Feb 24, 2026
f772fe6
fix unassignable array
winapiadmin Feb 24, 2026
6558d7e
Update types.h
winapiadmin Feb 25, 2026
d1c489f
prevent MSVC extension
winapiadmin Feb 25, 2026
c737a76
Use constexpr START_FEN in _Position constructor
winapiadmin Feb 25, 2026
d060fa7
fix compile error
winapiadmin Feb 25, 2026
3c7b880
Overload set_fen with default parameter value
winapiadmin Feb 25, 2026
a8b4200
Change START_FEN to use auto type deduction
winapiadmin Feb 25, 2026
b02b787
Update moves_io.cpp
winapiadmin Feb 25, 2026
3c477e5
Improve castling move logic for chess960
winapiadmin Feb 25, 2026
c2b39af
Fix formatting in castling case of move handling
winapiadmin Feb 25, 2026
20e44dd
Add push event trigger to clang-format workflow
winapiadmin Feb 25, 2026
0c59bf0
Apply clang-format
actions-user Feb 25, 2026
fe6f9f2
fix compile errors
winapiadmin Feb 25, 2026
31def46
Apply clang-format
actions-user Feb 25, 2026
d01601a
Update moves_io.cpp
winapiadmin Feb 25, 2026
9053656
Add GitHub Actions workflow for CMake builds
winapiadmin Feb 25, 2026
2f4c126
Update GitHub Actions to trigger on push and pull_request
winapiadmin Feb 25, 2026
fb6f4b6
Fix template usage in chess960 castling check
winapiadmin Feb 25, 2026
a62614e
Update try_compile.yml
winapiadmin Feb 25, 2026
bfbbef8
Update position.h
winapiadmin Feb 25, 2026
03d0932
Update position.h
winapiadmin Feb 25, 2026
c870484
Update fwd_decl.h
winapiadmin Feb 25, 2026
ee29712
Apply clang-format
actions-user Feb 25, 2026
10c851d
Update fwd_decl.h
winapiadmin Feb 25, 2026
8f26ec0
Apply clang-format
actions-user Feb 25, 2026
4763730
Update position.h
winapiadmin Feb 25, 2026
85f9728
Apply clang-format
actions-user Feb 25, 2026
0dcf50d
revert commit
winapiadmin Feb 25, 2026
a6e3844
Apply clang-format
actions-user Feb 25, 2026
b2f3b92
Update tests.cpp
winapiadmin Feb 25, 2026
16cd43a
Apply clang-format
actions-user Feb 25, 2026
2c92281
fix undefined behavior on invalid move
winapiadmin Feb 26, 2026
8092f6c
Apply clang-format
actions-user Feb 26, 2026
f5baba8
Update clang-format.yml
winapiadmin Feb 26, 2026
0bcfbdd
fix #35 (#36)
winapiadmin Mar 1, 2026
41cc66c
little bit of small patches (#37)
winapiadmin Mar 1, 2026
1c499b6
Update position.cpp
winapiadmin Mar 2, 2026
f54bc07
Update cmake-multi-platform.yml
winapiadmin Mar 2, 2026
ca684e9
Update try_compile.yml
winapiadmin Mar 2, 2026
78c95ec
Update and rename cmake-multi-platform.yml to test.yml
winapiadmin Mar 2, 2026
c59195c
Update position.h
winapiadmin Mar 2, 2026
18b1811
fixed (break when same hash, not counting)
winapiadmin Mar 2, 2026
776d0ee
tiny more test and tidy up code
winapiadmin Mar 20, 2026
0e6db85
Apply clang-format
actions-user Mar 20, 2026
0d41592
Update clang-format.yml
winapiadmin Mar 20, 2026
d7ac346
Update test.yml
winapiadmin Mar 20, 2026
0fbca1a
simplification
winapiadmin Mar 21, 2026
85545c0
Apply clang-format
actions-user Mar 21, 2026
8901a56
compile error fix and add new feature: disabling testing (yah look at…
winapiadmin Mar 21, 2026
d134ef4
Merge branch 'maintaince_1' of https://github.com/winapiadmin/chessli…
winapiadmin Mar 21, 2026
599bfc1
unlocked time limit (it was a problem?)
winapiadmin Mar 22, 2026
0f92269
Update test.yml
winapiadmin Mar 22, 2026
8c2a1bd
Update position.cpp
winapiadmin Mar 22, 2026
008b512
Apply clang-format
actions-user Mar 22, 2026
9ad396e
Update position.cpp
winapiadmin Mar 22, 2026
e384906
Apply clang-format
actions-user Mar 22, 2026
5684204
castling fix
winapiadmin Mar 22, 2026
53ea3e5
Apply clang-format
actions-user Mar 22, 2026
166d621
disable timeout
winapiadmin Mar 22, 2026
4e2baa2
Update test.yml
winapiadmin Mar 22, 2026
cbc28ec
fully disable timeout
winapiadmin Mar 22, 2026
f6f478c
Update position.cpp
winapiadmin Mar 22, 2026
b32a718
Apply clang-format
actions-user Mar 22, 2026
98cefa6
ignore syntactically illegal FEN castling input (clean them)
winapiadmin Mar 22, 2026
551ed6e
Apply clang-format
actions-user Mar 22, 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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./** text=auto eol=lf
4 changes: 4 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ Test log from the tester.
**Hardware/Software info**

List about the OS, hardware, compiler and tester.

**Specifically, if the issue is reported by logic analysis, provide solution if applicable.**

solution to the issue if applicable. If not, please provide the logic analysis data and your interpretation of it.
7 changes: 5 additions & 2 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ name: clang-format
on:
pull_request:
branches: [ "main" ]

push:
branches-ignore:
- main
jobs:
format:
if: github.actor != 'github-actions[bot]'
Expand All @@ -14,6 +16,7 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Install clang-format
Expand All @@ -30,4 +33,4 @@ jobs:
git config user.name "GitHub Actions"
git commit -am "Apply clang-format"
git push
fi
fi
73 changes: 73 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: test

on:
pull_request:
branches: [ "main" ]

jobs:
build:
if: ${{ !endsWith(github.event.pull_request.title, 'no functional change') }}
runs-on: ${{ matrix.os }}

strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]
build_type: [Debug, Release]
c_compiler: [gcc, clang, cl]

include:
# Windows
- os: windows-latest
c_compiler: cl
cpp_compiler: cl
- os: windows-latest
c_compiler: clang
cpp_compiler: clang++
- os: windows-latest
c_compiler: gcc
cpp_compiler: g++

# Linux
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++

exclude:
- os: ubuntu-latest
c_compiler: cl

steps:
- uses: actions/checkout@v4

- name: Set build dir
id: vars
shell: bash
run: echo "dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"

- name: Configure CMake
shell: bash
run: |
cmake -B "${{ steps.vars.outputs.dir }}" \
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DSANITIZERS="address,undefined" \
-DDART_TESTING_TIMEOUT=0 \
-S "${{ github.workspace }}"

- name: Build
run: cmake --build ${{ steps.vars.outputs.dir }} --config ${{ matrix.build_type }}

- name: Test
working-directory: ${{ steps.vars.outputs.dir }}
shell: bash
run: |
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
ctest --build-config ${{ matrix.build_type }} --verbose -j 4 --timeout 0
else
ctest --verbose -j 4 --timeout 0
fi
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
name: CMake on multiple platforms
name: Compilation

on:
pull_request:
branches: [ "main" ]
pull_request:

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]
build_type: [Debug, Release]
build_type: [Debug]
c_compiler: [gcc, clang, cl]

include:
Expand Down Expand Up @@ -52,10 +51,6 @@ jobs:
run: |
CXX_FLAGS=""
LINK_FLAGS=""
if [[ "${{ matrix.os }}" == "ubuntu-latest" && "${{ matrix.build_type }}" == "Debug" ]]; then
CXX_FLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer -g"
LINK_FLAGS="-fsanitize=address,undefined"
fi

cmake -B "${{ steps.vars.outputs.dir }}" \
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \
Expand All @@ -67,13 +62,3 @@ jobs:

- name: Build
run: cmake --build ${{ steps.vars.outputs.dir }} --config ${{ matrix.build_type }}

- name: Test
working-directory: ${{ steps.vars.outputs.dir }}
shell: bash
run: |
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
ctest --build-config ${{ matrix.build_type }} --verbose -j 4
else
ctest --verbose -j 4
fi
28 changes: 16 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
out/
build/
.vs/
# Ignore everything
*

# Allow source and essential files
!*.cpp
!*.h
!CMakeLists.txt
!README.md
!LICENSE
!CMakeLists.txt
!.gitignore
!.gitattributes
CMakePresets.json
CMakeSettings.json
*.s
.vscode
.cache
deps/*
!deps/
*
!.github/**
!.github/
# Ignore build/editor junk
build/
out/
.vs/
.vscode/
.cache/
cmake-*/
# Ignore asm outputs
*.s
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

151 changes: 27 additions & 124 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ project(chesslib LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
option(ENABLE_COVERAGE "Enable coverage reporting" OFF)

# --- Compiler tuning ---
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
Expand Down Expand Up @@ -32,10 +32,6 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
add_compile_options(/constexpr:steps2000000000 /constexpr:depth1024 ${ARCH_FLAG})
endif()

if(ENABLE_COVERAGE)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF)
endif()
add_compile_definitions(GENERATE_AT_RUNTIME)
if(CMAKE_BUILD_TYPE MATCHES "Debug")
add_compile_definitions(_DEBUG)
Expand All @@ -48,125 +44,32 @@ set(SOURCES
add_library(chesslib STATIC ${SOURCES})
target_include_directories(chesslib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
# --- Enable CTest integration ---
enable_testing()
include(FetchContent)
FetchContent_Declare(
doctest
GIT_REPOSITORY https://github.com/doctest/doctest.git
GIT_TAG v2.4.12
)
FetchContent_MakeAvailable(doctest)
# --- Test executable ---
add_executable(test_chess
tests.cpp
)
add_executable(NonImportantTests
non_core_tests.cpp
)
target_link_libraries(test_chess PRIVATE chesslib)
target_include_directories(test_chess PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${doctest_SOURCE_DIR})
target_link_libraries(NonImportantTests PRIVATE chesslib)
target_include_directories(NonImportantTests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${doctest_SOURCE_DIR})
add_test(NAME test_core COMMAND test_chess)
add_test(NAME api_tests COMMAND NonImportantTests)
if(ENABLE_COVERAGE)

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
foreach(t chesslib test_chess NonImportantTests)
target_compile_options(${t} PRIVATE
--coverage
-O0
)
target_link_options(${t} PRIVATE
--coverage
)
endforeach()

find_program(GCOVR gcovr REQUIRED)

add_custom_target(coverage
COMMAND ${CMAKE_COMMAND} -E make_directory coverage
COMMAND ${CMAKE_CTEST_COMMAND}
COMMAND ${GCOVR}
-r ${CMAKE_SOURCE_DIR}
--html
--html-details
-o coverage/index.html
--exclude-directories tests
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Generating GCC coverage report"
)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
foreach(t chesslib test_chess NonImportantTests)
target_compile_options(${t} PRIVATE
-fprofile-instr-generate
-fcoverage-mapping
-O0
)
target_link_options(${t} PRIVATE
-fprofile-instr-generate
)
endforeach()

if(WIN32)

find_program(LLVM_PROFDATA llvm-profdata REQUIRED)
find_program(LLVM_COV llvm-cov REQUIRED)

add_custom_target(coverage
COMMAND ${CMAKE_COMMAND} -E make_directory coverage

COMMAND ${CMAKE_COMMAND} -E env
LLVM_PROFILE_FILE=coverage/coverage.profraw
CTEST_PARALLEL_LEVEL=1
${CMAKE_CTEST_COMMAND}

COMMAND ${LLVM_PROFDATA} merge
-sparse
coverage/coverage.profraw
-o coverage/coverage.profdata

COMMAND ${LLVM_COV} show
$<TARGET_FILE:test_chess>
$<TARGET_FILE:NonImportantTests>
-instr-profile=coverage/coverage.profdata
-format=html
-output-dir=coverage
-ignore-filename-regex="tests|doctest"
-Xdemangler=llvm-cxxfilt

WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Generating Clang coverage report (Windows)"
)
else()

find_program(LLVM_PROFDATA llvm-profdata REQUIRED)
find_program(LLVM_COV llvm-cov REQUIRED)

add_custom_target(coverage
COMMAND ${CMAKE_COMMAND} -E make_directory coverage

COMMAND ${CMAKE_COMMAND} -E env
LLVM_PROFILE_FILE=coverage/%m.profraw
${CMAKE_CTEST_COMMAND}

COMMAND ${LLVM_PROFDATA} merge
-sparse
coverage
-o coverage/coverage.profdata

COMMAND ${LLVM_COV} show
$<TARGET_FILE:test_chess>
$<TARGET_FILE:NonImportantTests>
-instr-profile=coverage/coverage.profdata
-format=html
-output-dir=coverage
-ignore-filename-regex="tests|doctest"
-Xdemangler=c++filt

WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Generating Clang coverage report"
)
include(CTest)

if(BUILD_TESTING)
include(FetchContent)
FetchContent_Declare(
doctest
GIT_REPOSITORY https://github.com/doctest/doctest.git
GIT_TAG v2.4.12
)
FetchContent_MakeAvailable(doctest)

# --- Test executable ---
add_executable(test_chess tests.cpp)
add_executable(NonImportantTests non_core_tests.cpp)

target_link_libraries(test_chess PRIVATE chesslib doctest::doctest)
target_link_libraries(NonImportantTests PRIVATE chesslib doctest::doctest)

add_test(NAME test_core COMMAND test_chess)
add_test(NAME api_tests COMMAND NonImportantTests)
if (UNIX AND CMAKE_BUILD_TYPE MATCHES "Debug")
set(SANITIZERS "" CACHE STRING "sanitizers such as undefined,address")

if (NOT "${SANITIZERS}" STREQUAL "")
add_compile_options(-fsanitize=${SANITIZERS} -fno-omit-frame-pointer)
add_link_options(-fsanitize=${SANITIZERS})
endif()
endif()

Expand Down
12 changes: 9 additions & 3 deletions attacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ extern const std::array<Bitboard, 0x1480> BishopAttacks;
* @param b
* @return
*/
template <Direction direction> [[nodiscard]] static constexpr Bitboard shift(const Bitboard b) {
ASSUME(direction == NORTH || direction == EAST || direction == SOUTH || direction == WEST || direction == NORTH_EAST ||
direction == SOUTH_EAST || direction == SOUTH_WEST || direction == NORTH_WEST);
[[nodiscard]] static constexpr Bitboard shift(const Bitboard b, Direction direction) {
switch (direction) {
case Direction::NORTH:
return b << 8;
Expand All @@ -166,8 +164,16 @@ template <Direction direction> [[nodiscard]] static constexpr Bitboard shift(con
return (b & ~MASK_FILE[7]) >> 7;
default:
UNREACHABLE();
return 0;
}
}
/**
* @brief Shifts a bitboard in a given direction
* @tparam direction
* @param b
* @return
*/
template <Direction direction> [[nodiscard]] static constexpr Bitboard shift(const Bitboard b) { return shift(b, direction); }

/**
* @brief
Expand Down
Loading