diff --git a/.github/workflows/docker_build_push.yaml b/.github/workflows/docker_build_push.yaml index 9f5ac40..cb7f654 100644 --- a/.github/workflows/docker_build_push.yaml +++ b/.github/workflows/docker_build_push.yaml @@ -1,4 +1,4 @@ -name: Build and Push Docker Image +name: Build Push Linux Docker Image on: workflow_dispatch: diff --git a/.github/workflows/ci.yaml b/.github/workflows/linux-build.yaml similarity index 95% rename from .github/workflows/ci.yaml rename to .github/workflows/linux-build.yaml index b6f833b..89881d9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/linux-build.yaml @@ -1,4 +1,4 @@ -name: CI +name: Linux Build on: push: @@ -9,7 +9,7 @@ permissions: packages: read jobs: - linux: + linux-build: runs-on: ubuntu-latest container: @@ -47,7 +47,7 @@ jobs: exit $CONFIGURE_EXIT_CODE - - name: Build + - name: Build (${{ matrix.preset }}) run: | set +e cmake --build --preset ${{ matrix.preset }} 2>&1 | tee build_output.txt @@ -69,7 +69,7 @@ jobs: exit $BUILD_EXIT_CODE - - name: Test + - name: Test (${{ matrix.preset }}) run: | set +e ctest --preset ${{ matrix.preset }} --output-on-failure 2>&1 | tee test_output.txt diff --git a/.github/workflows/windows-build.yaml b/.github/workflows/windows-build.yaml new file mode 100644 index 0000000..5848882 --- /dev/null +++ b/.github/workflows/windows-build.yaml @@ -0,0 +1,93 @@ +name: Windows Build + +on: + push: + workflow_dispatch: + +jobs: + windows-build: + runs-on: windows-2022 + + strategy: + matrix: + preset: [ msvc_debug, msvc_release ] + + steps: + - uses: actions/checkout@v4 + + - name: Configure (${{ matrix.preset }}) + env: + VCPKG_ROOT: C:\vcpkg + shell: pwsh + run: | + $outputFile = "configure_output.txt" + + cmake --preset ${{ matrix.preset }} 2>&1 | Tee-Object -FilePath $outputFile + $exitCode = $LASTEXITCODE + + if ($exitCode -eq 0) { + Add-Content $env:GITHUB_STEP_SUMMARY "
🟢 Configure Results (click to expand)" + } else { + Add-Content $env:GITHUB_STEP_SUMMARY "## 🔴 Configure Results" + } + + Add-Content $env:GITHUB_STEP_SUMMARY "" + Add-Content $env:GITHUB_STEP_SUMMARY '```' + Get-Content $outputFile | Add-Content $env:GITHUB_STEP_SUMMARY + Add-Content $env:GITHUB_STEP_SUMMARY '```' + + if ($exitCode -eq 0) { + Add-Content $env:GITHUB_STEP_SUMMARY "
" + } + + exit $exitCode + + - name: Build (${{ matrix.preset }}) + shell: pwsh + run: | + $outputFile = "build_output.txt" + + cmake --build --preset ${{ matrix.preset }} 2>&1 | Tee-Object -FilePath $outputFile + $exitCode = $LASTEXITCODE + + if ($exitCode -eq 0) { + Add-Content $env:GITHUB_STEP_SUMMARY "
🟢 Build Results (click to expand)" + } else { + Add-Content $env:GITHUB_STEP_SUMMARY "## 🔴 Build Results" + } + + Add-Content $env:GITHUB_STEP_SUMMARY "" + Add-Content $env:GITHUB_STEP_SUMMARY '```' + Get-Content $outputFile | Add-Content $env:GITHUB_STEP_SUMMARY + Add-Content $env:GITHUB_STEP_SUMMARY '```' + + if ($exitCode -eq 0) { + Add-Content $env:GITHUB_STEP_SUMMARY "
" + } + + exit $exitCode + + - name: Test (${{ matrix.preset }}) + shell: pwsh + run: | + $outputFile = "test_output.txt" + + ctest --preset ${{ matrix.preset }} --output-on-failure 2>&1 | Tee-Object -FilePath $outputFile + $exitCode = $LASTEXITCODE + + if ($exitCode -eq 0) { + Add-Content $env:GITHUB_STEP_SUMMARY "
🟢 Test Results (click to expand)" + } else { + Add-Content $env:GITHUB_STEP_SUMMARY "## 🔴 Test Results" + } + + Add-Content $env:GITHUB_STEP_SUMMARY "" + Add-Content $env:GITHUB_STEP_SUMMARY '```' + Get-Content $outputFile | Add-Content $env:GITHUB_STEP_SUMMARY + Add-Content $env:GITHUB_STEP_SUMMARY '```' + + if ($exitCode -eq 0) { + Add-Content $env:GITHUB_STEP_SUMMARY "
" + } + + exit $exitCode diff --git a/CMakePresets.json b/CMakePresets.json index 207a358..94162dd 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -66,11 +66,13 @@ }, { "name": "msvc_debug", - "configurePreset": "msvc_debug" + "configurePreset": "msvc_debug", + "configuration": "Debug" }, { "name": "msvc_release", - "configurePreset": "msvc_release" + "configurePreset": "msvc_release", + "configuration": "Release" } ], "testPresets": [ @@ -84,11 +86,13 @@ }, { "name": "msvc_debug", - "configurePreset": "msvc_debug" + "configurePreset": "msvc_debug", + "configuration": "Debug" }, { "name": "msvc_release", - "configurePreset": "msvc_release" + "configurePreset": "msvc_release", + "configuration": "Release" } ], "packagePresets": [ diff --git a/docker/ubuntu/Dockerfile b/docker/ubuntu/Dockerfile index 2f6421f..069f011 100644 --- a/docker/ubuntu/Dockerfile +++ b/docker/ubuntu/Dockerfile @@ -1,8 +1,6 @@ # Commands: -# [build] docker build -t ghr-chess-engine-ubuntu . -f docker/ubuntu/Dockerfile -# [run] docker run -it --rm ghr-chess-engine-ubuntu -# [configure cmake] cmake --preset=clang_release -# [build cmake] cmake --build --preset=clang_release +# [build] docker build -t bitbishop-ubuntu . -f docker/ubuntu/Dockerfile +# [run] docker run -it --rm bitbishop-ubuntu FROM ubuntu:24.04 diff --git a/include/bitbishop/moves/pawn_move_gen.hpp b/include/bitbishop/moves/pawn_move_gen.hpp index 7bb9b98..7905992 100644 --- a/include/bitbishop/moves/pawn_move_gen.hpp +++ b/include/bitbishop/moves/pawn_move_gen.hpp @@ -102,7 +102,12 @@ constexpr bool is_promotion_rank(Square sq, Color c) { return c == Color::WHITE * @return true if the capture geometry is valid for en passant, false otherwise */ constexpr bool can_capture_en_passant(Square from, Square epsq, Color side) noexcept { - int df = std::abs(int(from.file()) - int(epsq.file())); + // MSVC have not yet made std::abs() constexpr for C++ 23, forcing us to define a generic constexpr one... + // For this, lets apply the abs() function manually. This is sad, but you know, MSVC... + // The code should not adapt to the compiler for the same language, the compiler should... + int df = int(from.file()) - int(epsq.file()); + df = (df < 0) ? -df : df; + if (df != 1) return false; if (side == Color::WHITE && from.rank() == 4 && epsq.rank() == 5) return true; if (side == Color::BLACK && from.rank() == 3 && epsq.rank() == 2) return true;