From e9e969e57e8110034f613e69351dc87fc2707d27 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Mon, 27 Apr 2026 16:07:45 +0700 Subject: [PATCH 01/14] copyright and corrected code --- CMakeLists.txt | 17 +++++++++++++++++ attacks.cpp | 18 ++++++++++++++++++ attacks.h | 19 +++++++++++++++++++ bitboard.h | 18 ++++++++++++++++++ chess960_tests.cpp | 18 ++++++++++++++++++ fwd_decl.h | 18 ++++++++++++++++++ movegen.cpp | 24 ++++++++++++++++++++++++ movegen.h | 18 ++++++++++++++++++ moves_io.cpp | 27 +++++++++++++++++++++++++-- moves_io.h | 21 +++++++++++++++++++++ non_core_tests.cpp | 18 ++++++++++++++++++ position.cpp | 27 ++++++++++++++++++--------- position.h | 33 +++++++++++++++++++++++++-------- printers.cpp | 18 ++++++++++++++++++ printers.h | 18 ++++++++++++++++++ tests.cpp | 24 ++++++++++++++++++++++++ types.h | 46 +++++++++++++++++++++++++++++++++++++++------- zobrist.cpp | 18 ++++++++++++++++++ zobrist.h | 18 ++++++++++++++++++ 19 files changed, 392 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f34095..b1297bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,20 @@ +# a chess library (bonus: you can integrate more piece types!) which +# supports Chess960 and is decently fast enough +# Copyright (C) 2025-2026 winapiadmin +# +# This program 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. +# +# This program 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 this program. If not, see . +# cmake_minimum_required(VERSION 3.16) project(chesslib LANGUAGES CXX) diff --git a/attacks.cpp b/attacks.cpp index 69d0efc..733a42f 100644 --- a/attacks.cpp +++ b/attacks.cpp @@ -1,3 +1,21 @@ +/* + a chess library (bonus: you can integrate more piece types!) which + supports Chess960 and is decently fast enough + Copyright (C) 2025-2026 winapiadmin + + This program 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. + + This program 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 this program. If not, see . +*/ #include "attacks.h" namespace chess::_chess { diff --git a/attacks.h b/attacks.h index 5027d84..40d476b 100644 --- a/attacks.h +++ b/attacks.h @@ -1,3 +1,22 @@ +/* + a chess library (bonus: you can integrate more piece types!) which + supports Chess960 and is decently fast enough + Copyright (C) 2025-2026 winapiadmin + + This program 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. + + This program 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 this program. If not, see . +*/ + #pragma once #include "bitboard.h" #include "fwd_decl.h" diff --git a/bitboard.h b/bitboard.h index cc635cb..0aa7eae 100644 --- a/bitboard.h +++ b/bitboard.h @@ -1,3 +1,21 @@ +/* + a chess library (bonus: you can integrate more piece types!) which + supports Chess960 and is decently fast enough + Copyright (C) 2025-2026 winapiadmin + + This program 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. + + This program 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 this program. If not, see . +*/ #pragma once #include "types.h" diff --git a/chess960_tests.cpp b/chess960_tests.cpp index a5c5666..aa7915a 100644 --- a/chess960_tests.cpp +++ b/chess960_tests.cpp @@ -1,3 +1,21 @@ +/* + a chess library (bonus: you can integrate more piece types!) which + supports Chess960 and is decently fast enough + Copyright (C) 2025-2026 winapiadmin + + This program 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. + + This program 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 this program. If not, see . +*/ #define DOCTEST_CONFIG_IMPLEMENT #define DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS #include "moves_io.h" diff --git a/fwd_decl.h b/fwd_decl.h index 87e64e2..9f822ca 100644 --- a/fwd_decl.h +++ b/fwd_decl.h @@ -1,3 +1,21 @@ +/* + a chess library (bonus: you can integrate more piece types!) which + supports Chess960 and is decently fast enough + Copyright (C) 2025-2026 winapiadmin + + This program 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. + + This program 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 this program. If not, see . +*/ #pragma once #include #include diff --git a/movegen.cpp b/movegen.cpp index d92e78a..60f5155 100644 --- a/movegen.cpp +++ b/movegen.cpp @@ -1,3 +1,27 @@ +/* + a chess library (bonus: you can integrate more piece types!) which + supports Chess960 and is decently fast enough + Copyright (C) 2025-2026 winapiadmin + + This program 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. + + This program 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 this program. If not, see . +*/ +// AVX512 and scalar bb-movegens + +// License: https://github.com/official-stockfish/Stockfish/blob/master/COPYING.txt +// movegen references + +// License: https://github.com/Disservin/chess-library/blob/master/LICENSE #include "movegen.h" #include "position.h" diff --git a/movegen.h b/movegen.h index df2eb41..bb6aea0 100644 --- a/movegen.h +++ b/movegen.h @@ -1,3 +1,21 @@ +/* + a chess library (bonus: you can integrate more piece types!) which + supports Chess960 and is decently fast enough + Copyright (C) 2025-2026 winapiadmin + + This program 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. + + This program 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 this program. If not, see . +*/ #pragma once #include "fwd_decl.h" #include diff --git a/moves_io.cpp b/moves_io.cpp index 06a89fe..339bf8b 100644 --- a/moves_io.cpp +++ b/moves_io.cpp @@ -1,3 +1,27 @@ +/* + a chess library (bonus: you can integrate more piece types!) which + supports Chess960 and is decently fast enough + Copyright (C) 2025-2026 winapiadmin + + This program 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. + + This program 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 this program. If not, see . +*/ +// UCI moves parsing + +// License: https://github.com/Disservin/chess-library/blob/master/LICENSE +// pjpuzzler/cpp-chess doesn't have license, but it is linked to niklasf/python-chess + +// License: https://github.com/niklasf/python-chess/blob/master/LICENSE.txt #include "moves_io.h" #include "position.h" #include "types.h" @@ -240,10 +264,9 @@ template Move parseSan(const _Position &pos, std: if (src_square == SQ_NONE) THROW_IF_EXCEPTIONS_ON(IllegalMoveException("illegal san: '" + _san + "' in " + pos.fen())); prefix.resize(prefix.size() - 2); - has_src_square = true; } } - + has_src_square = src_square != SQ_NONE; // 7) Detect piece letter at front if present PieceType piece_type = NO_PIECE_TYPE; if (!prefix.empty()) { diff --git a/moves_io.h b/moves_io.h index 5dccb74..7afe49d 100644 --- a/moves_io.h +++ b/moves_io.h @@ -1,3 +1,24 @@ +/* + a chess library (bonus: you can integrate more piece types!) which + supports Chess960 and is decently fast enough + Copyright (C) 2025-2026 winapiadmin + + This program 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. + + This program 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 this program. If not, see . +*/ +// pjpuzzler/cpp-chess doesn't have license, but it is linked to niklasf/python-chess + +// License: https://github.com/niklasf/python-chess/blob/master/LICENSE.txt #pragma once #include "fwd_decl.h" #include diff --git a/non_core_tests.cpp b/non_core_tests.cpp index c6f6f51..5a8ae98 100644 --- a/non_core_tests.cpp +++ b/non_core_tests.cpp @@ -1,3 +1,21 @@ +/* + a chess library (bonus: you can integrate more piece types!) which + supports Chess960 and is decently fast enough + Copyright (C) 2025-2026 winapiadmin + + This program 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. + + This program 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 this program. If not, see . +*/ #define DOCTEST_CONFIG_IMPLEMENT #ifndef __EXCEPTIONS #define DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS diff --git a/position.cpp b/position.cpp index fb0b5b7..c1636a5 100644 --- a/position.cpp +++ b/position.cpp @@ -1,3 +1,21 @@ +/* + a chess library (bonus: you can integrate more piece types!) which + supports Chess960 and is decently fast enough + Copyright (C) 2025-2026 winapiadmin + + This program 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. + + This program 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 this program. If not, see . +*/ #include "position.h" #include "movegen.h" #include "moves_io.h" @@ -13,17 +31,8 @@ #define _POSSIBLY_CONSTEXPR const #endif -#if defined(__EXCEPTIONS) -#define THROW_IF_EXCEPTIONS_ON(stuff) throw stuff -#else -#define THROW_IF_EXCEPTIONS_ON(stuff) ((void)0) -#endif #if defined(_DEBUG) || !defined(NDEBUG) #define INVALID_ARG_IF(c, s) assert(!(c) && s) -#elif defined(__EXCEPTIONS) -#define INVALID_ARG_IF(c, s) \ - if (c) \ - THROW_IF_EXCEPTIONS_ON(std::invalid_argument(s)) #else #define INVALID_ARG_IF(c, s) #endif diff --git a/position.h b/position.h index 1ca73d6..4fad49c 100644 --- a/position.h +++ b/position.h @@ -1,3 +1,21 @@ +/* + a chess library (bonus: you can integrate more piece types!) which + supports Chess960 and is decently fast enough + Copyright (C) 2025-2026 winapiadmin + + This program 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. + + This program 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 this program. If not, see . +*/ #pragma once #include "attacks.h" #include "bitboard.h" @@ -63,9 +81,11 @@ template constexpr MoveGenType operator&(MoveGenType a, M using U = std::underlying_type_t; return static_cast(static_cast(a) & static_cast(b)); } + template constexpr MoveGenType operator|(MoveGenType a, MoveGenType b) { using U = std::underlying_type_t; - return static_cast(static_cast(a) | static_cast(b)); + return static_cast(static_cast(a) | + static_cast(b)); // NOLINT(clang-analyzer-optin.core.EnumCastOutOfRange) } template ::value>> class _Position { private: @@ -385,11 +405,8 @@ template = ply; } inline int repetition_count() const { return state().repetition; } - // Test if it's draw of 75 move rule (that forces everyone to draw). It doesn't consider checkmates. + // Test if it's draw of 50 move rule (that forces everyone to draw). It doesn't consider checkmates. inline bool is_draw(int ply) const { return rule50_count() > 99 || is_repetition(ply); } // Tests whether there has been at least one repetition // of positions since the last capture or pawn move. @@ -487,8 +504,8 @@ template = n; } inline bool chess960() const { return _chess960; } - inline bool is_seventyfive_moves(int n) const { return _is_halfmoves(150); } - inline bool is_fifty_moves(int n) const { return _is_halfmoves(150); } + inline bool is_seventyfive_moves() const { return _is_halfmoves(150); } + inline bool is_fifty_moves() const { return _is_halfmoves(100); } inline bool is_fivefold_repetition() const { return is_repetition(5); } inline bool is_attacked_by(Color color, Square sq, Bitboard occupied = 0) const { Bitboard occ_bb = occupied ? occupied : this->occ(); diff --git a/printers.cpp b/printers.cpp index 74e69cc..75f920d 100644 --- a/printers.cpp +++ b/printers.cpp @@ -1,3 +1,21 @@ +/* + a chess library (bonus: you can integrate more piece types!) which + supports Chess960 and is decently fast enough + Copyright (C) 2025-2026 winapiadmin + + This program 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. + + This program 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 this program. If not, see . +*/ #include "printers.h" #include "moves_io.h" #include "position.h" diff --git a/printers.h b/printers.h index 42581c0..1028bb4 100644 --- a/printers.h +++ b/printers.h @@ -1,3 +1,21 @@ +/* + a chess library (bonus: you can integrate more piece types!) which + supports Chess960 and is decently fast enough + Copyright (C) 2025-2026 winapiadmin + + This program 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. + + This program 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 this program. If not, see . +*/ #pragma once #include "fwd_decl.h" #include diff --git a/tests.cpp b/tests.cpp index 4b9ee33..1032940 100644 --- a/tests.cpp +++ b/tests.cpp @@ -1,3 +1,21 @@ +/* + a chess library (bonus: you can integrate more piece types!) which + supports Chess960 and is decently fast enough + Copyright (C) 2025-2026 winapiadmin + + This program 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. + + This program 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 this program. If not, see . +*/ #define DOCTEST_CONFIG_IMPLEMENT #define DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS #include "moves_io.h" @@ -188,6 +206,8 @@ template uint64_t perft(_Po pos.template legals(moves); if constexpr (EnableDiv) for (const Move &m : moves) { + pos.doNullMove(); + pos.undoMove(); std::cout << m << ": 1\n"; } return moves.size(); @@ -197,7 +217,11 @@ template uint64_t perft(_Po uint64_t total = 0; for (const Move &m : moves) { pos.template doMove(m); + pos.doNullMove(); + pos.undoMove(); const uint64_t nodes = perft(pos, depth - 1); + pos.doNullMove(); + pos.undoMove(); pos.undoMove(); if constexpr (EnableDiv) std::cout << m << ": " << nodes << '\n'; diff --git a/types.h b/types.h index f6177f8..f88af18 100644 --- a/types.h +++ b/types.h @@ -1,3 +1,26 @@ +/* + a chess library (bonus: you can integrate more piece types!) which + supports Chess960 and is decently fast enough + Copyright (C) 2025-2026 winapiadmin + + This program 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. + + This program 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 this program. If not, see . +*/ + +// enums, structures, Move class taken from Stockfish + +// License: https://github.com/official-stockfish/Stockfish/blob/master/COPYING.txt + #pragma once #include "fwd_decl.h" @@ -111,6 +134,15 @@ enum Direction : int8_t { SOUTH_EAST = SOUTH + EAST, SOUTH_WEST = SOUTH + WEST, NORTH_WEST = NORTH + WEST, + DOUBLE_NORTH = 2*NORTH, + DOUBLE_EAST = 2*EAST, + DOUBLE_SOUTH = 2*SOUTH, + DOUBLE_WEST = 2*WEST, + DOUBLE_NORTH_EAST = 2*NORTH_EAST, + DOUBLE_SOUTH_EAST = 2*SOUTH_EAST, + DOUBLE_SOUTH_WEST = 2*SOUTH_WEST, + DOUBLE_NORTH_WEST = 2*NORTH_WEST, + DIR_NONE = 0 }; // clang-format on @@ -266,23 +298,23 @@ enum CastlingRights : int8_t { constexpr CastlingRights operator&(Color c, CastlingRights cr) { return CastlingRights((c == WHITE ? WHITE_CASTLING : BLACK_CASTLING) & cr); } -// Bitwise OR assignment operator + inline CastlingRights &operator|=(CastlingRights &a, CastlingRights b) { - a = static_cast(static_cast(a) | static_cast(b)); - return a; + return a = static_cast(static_cast(a) | + static_cast(b)); // NOLINT(clang-analyzer-optin.core.EnumCastOutOfRange) } -// Bitwise OR assignment operator inline CastlingRights operator|(CastlingRights a, CastlingRights b) { - return static_cast(static_cast(a) | static_cast(b)); + return static_cast(static_cast(a) | + static_cast(b)); // NOLINT(clang-analyzer-optin.core.EnumCastOutOfRange) } -// Bitwise OR assignment operator inline CastlingRights &operator&=(CastlingRights &a, CastlingRights b) { a = static_cast(static_cast(a) & static_cast(b)); return a; } inline CastlingRights operator~(CastlingRights a) { - return static_cast(static_cast(a) ^ ANY_CASTLING); + return static_cast(static_cast(a) ^ + ANY_CASTLING); // NOLINT(clang-analyzer-optin.core.EnumCastOutOfRange) } enum MoveType : uint16_t { NORMAL, PROMOTION = 1 << 14, EN_PASSANT = 2 << 14, CASTLING = 3 << 14 }; diff --git a/zobrist.cpp b/zobrist.cpp index 0d82cf5..f1f6811 100644 --- a/zobrist.cpp +++ b/zobrist.cpp @@ -1,3 +1,21 @@ +/* + a chess library (bonus: you can integrate more piece types!) which + supports Chess960 and is decently fast enough + Copyright (C) 2025-2026 winapiadmin + + This program 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. + + This program 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 this program. If not, see . +*/ #include "zobrist.h" #include "types.h" namespace chess::zobrist { diff --git a/zobrist.h b/zobrist.h index 020a8e3..3a43a5f 100644 --- a/zobrist.h +++ b/zobrist.h @@ -1,3 +1,21 @@ +/* + a chess library (bonus: you can integrate more piece types!) which + supports Chess960 and is decently fast enough + Copyright (C) 2025-2026 winapiadmin + + This program 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. + + This program 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 this program. If not, see . +*/ #pragma once #include #include From c7f42ae1735a35593018ec69961e06ab38820d91 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Mon, 27 Apr 2026 16:17:26 +0700 Subject: [PATCH 02/14] Normalize line endings --- .github/ISSUE_TEMPLATE/bug_report.md | 62 ++++---- .github/ISSUE_TEMPLATE/feature_request.md | 40 +++--- .github/workflows/clang-format.yml | 72 +++++----- .github/workflows/test.yml | 168 +++++++++++----------- .github/workflows/try_compile.yml | 128 ++++++++--------- 5 files changed, 235 insertions(+), 235 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index f91faa5..bce1ec4 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,32 +1,32 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: 'bug' -assignees: '' - ---- - -**Describe the bug** - -A clear and concise description of what the bug is. - -**Minimal, Reproducible Example** - -The code that's able to reproduce the bug - -**Partial test log** - -e.g. output from doctest/catch2 or your tester that's stripped to the failing test case - -**Full test log** - -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.** - +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: 'bug' +assignees: '' + +--- + +**Describe the bug** + +A clear and concise description of what the bug is. + +**Minimal, Reproducible Example** + +The code that's able to reproduce the bug + +**Partial test log** + +e.g. output from doctest/catch2 or your tester that's stripped to the failing test case + +**Full test log** + +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. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index bbcbbe7..72718d5 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -1,20 +1,20 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: '' -labels: '' -assignees: '' - ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index 2985327..c9a6cd8 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -1,36 +1,36 @@ -name: clang-format - -on: - pull_request: - branches: [ "main" ] - push: - branches-ignore: - - main -jobs: - format: - if: github.actor != 'github-actions[bot]' - runs-on: ubuntu-latest - permissions: - contents: write - - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.head_ref }} - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Install clang-format - run: sudo apt-get update && sudo apt-get install -y clang-format - - - name: Run clang-format - run: | - clang-format -i $(git ls-files '*.cpp' '*.hpp' '*.h' '*.c') - - - name: Commit and push changes - run: | - if ! git diff --quiet; then - git config user.email "actions@github.com" - git config user.name "GitHub Actions" - git commit -am "Apply clang-format" - git push - fi +name: clang-format + +on: + pull_request: + branches: [ "main" ] + push: + branches-ignore: + - main +jobs: + format: + if: github.actor != 'github-actions[bot]' + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Install clang-format + run: sudo apt-get update && sudo apt-get install -y clang-format + + - name: Run clang-format + run: | + clang-format -i $(git ls-files '*.cpp' '*.hpp' '*.h' '*.c') + + - name: Commit and push changes + run: | + if ! git diff --quiet; then + git config user.email "actions@github.com" + git config user.name "GitHub Actions" + git commit -am "Apply clang-format" + git push + fi diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 23bfde3..17309aa 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,84 +1,84 @@ -name: test - -on: - pull_request: - branches: [ "main" ] - paths: - - '**.c' - - '**.cpp' - - '**.h' - - '**.hpp' - -jobs: - build: - 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: | - if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then - if [[ "${{ matrix.cpp_compiler }}" == "clang++" ]]; then - SANITIZERS="memory,undefined" - else - SANITIZERS="address,undefined" - fi - fi - 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=${SANITIZERS} \ - -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 +name: test + +on: + pull_request: + branches: [ "main" ] + paths: + - '**.c' + - '**.cpp' + - '**.h' + - '**.hpp' + +jobs: + build: + 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: | + if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then + if [[ "${{ matrix.cpp_compiler }}" == "clang++" ]]; then + SANITIZERS="memory,undefined" + else + SANITIZERS="address,undefined" + fi + fi + 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=${SANITIZERS} \ + -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 diff --git a/.github/workflows/try_compile.yml b/.github/workflows/try_compile.yml index a1759f3..e727129 100644 --- a/.github/workflows/try_compile.yml +++ b/.github/workflows/try_compile.yml @@ -1,64 +1,64 @@ -name: Compilation - -on: - push: - branches-ignore: main -jobs: - build: - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: true - matrix: - os: [ubuntu-latest, windows-latest] - build_type: [Debug] - 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: | - CXX_FLAGS="" - LINK_FLAGS="" - - cmake -B "${{ steps.vars.outputs.dir }}" \ - -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \ - -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \ - -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ - -DCMAKE_CXX_FLAGS_DEBUG="$CXX_FLAGS" \ - -DCMAKE_EXE_LINKER_FLAGS="$LINK_FLAGS" \ - -S "${{ github.workspace }}" - - - name: Build - run: cmake --build ${{ steps.vars.outputs.dir }} --config ${{ matrix.build_type }} +name: Compilation + +on: + push: + branches-ignore: main +jobs: + build: + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest, windows-latest] + build_type: [Debug] + 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: | + CXX_FLAGS="" + LINK_FLAGS="" + + cmake -B "${{ steps.vars.outputs.dir }}" \ + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \ + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \ + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ + -DCMAKE_CXX_FLAGS_DEBUG="$CXX_FLAGS" \ + -DCMAKE_EXE_LINKER_FLAGS="$LINK_FLAGS" \ + -S "${{ github.workspace }}" + + - name: Build + run: cmake --build ${{ steps.vars.outputs.dir }} --config ${{ matrix.build_type }} From aa161d349a31e58b66f0049bbae489ad232c72f6 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Mon, 27 Apr 2026 16:18:47 +0700 Subject: [PATCH 03/14] fix newlines --- .github/ISSUE_TEMPLATE/bug_report.md | 62 ++++---- .github/ISSUE_TEMPLATE/feature_request.md | 40 +++--- .github/workflows/clang-format.yml | 72 +++++----- .github/workflows/test.yml | 168 +++++++++++----------- .github/workflows/try_compile.yml | 128 ++++++++--------- 5 files changed, 235 insertions(+), 235 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index bce1ec4..f91faa5 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,32 +1,32 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: 'bug' -assignees: '' - ---- - -**Describe the bug** - -A clear and concise description of what the bug is. - -**Minimal, Reproducible Example** - -The code that's able to reproduce the bug - -**Partial test log** - -e.g. output from doctest/catch2 or your tester that's stripped to the failing test case - -**Full test log** - -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.** - +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: 'bug' +assignees: '' + +--- + +**Describe the bug** + +A clear and concise description of what the bug is. + +**Minimal, Reproducible Example** + +The code that's able to reproduce the bug + +**Partial test log** + +e.g. output from doctest/catch2 or your tester that's stripped to the failing test case + +**Full test log** + +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. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 72718d5..bbcbbe7 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -1,20 +1,20 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: '' -labels: '' -assignees: '' - ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index c9a6cd8..2985327 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -1,36 +1,36 @@ -name: clang-format - -on: - pull_request: - branches: [ "main" ] - push: - branches-ignore: - - main -jobs: - format: - if: github.actor != 'github-actions[bot]' - runs-on: ubuntu-latest - permissions: - contents: write - - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.head_ref }} - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Install clang-format - run: sudo apt-get update && sudo apt-get install -y clang-format - - - name: Run clang-format - run: | - clang-format -i $(git ls-files '*.cpp' '*.hpp' '*.h' '*.c') - - - name: Commit and push changes - run: | - if ! git diff --quiet; then - git config user.email "actions@github.com" - git config user.name "GitHub Actions" - git commit -am "Apply clang-format" - git push - fi +name: clang-format + +on: + pull_request: + branches: [ "main" ] + push: + branches-ignore: + - main +jobs: + format: + if: github.actor != 'github-actions[bot]' + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Install clang-format + run: sudo apt-get update && sudo apt-get install -y clang-format + + - name: Run clang-format + run: | + clang-format -i $(git ls-files '*.cpp' '*.hpp' '*.h' '*.c') + + - name: Commit and push changes + run: | + if ! git diff --quiet; then + git config user.email "actions@github.com" + git config user.name "GitHub Actions" + git commit -am "Apply clang-format" + git push + fi diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 17309aa..23bfde3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,84 +1,84 @@ -name: test - -on: - pull_request: - branches: [ "main" ] - paths: - - '**.c' - - '**.cpp' - - '**.h' - - '**.hpp' - -jobs: - build: - 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: | - if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then - if [[ "${{ matrix.cpp_compiler }}" == "clang++" ]]; then - SANITIZERS="memory,undefined" - else - SANITIZERS="address,undefined" - fi - fi - 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=${SANITIZERS} \ - -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 +name: test + +on: + pull_request: + branches: [ "main" ] + paths: + - '**.c' + - '**.cpp' + - '**.h' + - '**.hpp' + +jobs: + build: + 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: | + if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then + if [[ "${{ matrix.cpp_compiler }}" == "clang++" ]]; then + SANITIZERS="memory,undefined" + else + SANITIZERS="address,undefined" + fi + fi + 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=${SANITIZERS} \ + -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 diff --git a/.github/workflows/try_compile.yml b/.github/workflows/try_compile.yml index e727129..a1759f3 100644 --- a/.github/workflows/try_compile.yml +++ b/.github/workflows/try_compile.yml @@ -1,64 +1,64 @@ -name: Compilation - -on: - push: - branches-ignore: main -jobs: - build: - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: true - matrix: - os: [ubuntu-latest, windows-latest] - build_type: [Debug] - 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: | - CXX_FLAGS="" - LINK_FLAGS="" - - cmake -B "${{ steps.vars.outputs.dir }}" \ - -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \ - -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \ - -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ - -DCMAKE_CXX_FLAGS_DEBUG="$CXX_FLAGS" \ - -DCMAKE_EXE_LINKER_FLAGS="$LINK_FLAGS" \ - -S "${{ github.workspace }}" - - - name: Build - run: cmake --build ${{ steps.vars.outputs.dir }} --config ${{ matrix.build_type }} +name: Compilation + +on: + push: + branches-ignore: main +jobs: + build: + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest, windows-latest] + build_type: [Debug] + 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: | + CXX_FLAGS="" + LINK_FLAGS="" + + cmake -B "${{ steps.vars.outputs.dir }}" \ + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \ + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \ + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ + -DCMAKE_CXX_FLAGS_DEBUG="$CXX_FLAGS" \ + -DCMAKE_EXE_LINKER_FLAGS="$LINK_FLAGS" \ + -S "${{ github.workspace }}" + + - name: Build + run: cmake --build ${{ steps.vars.outputs.dir }} --config ${{ matrix.build_type }} From 99f303914905d456e1afb47b3c6e605cd82298a4 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Thu, 30 Apr 2026 14:07:24 +0700 Subject: [PATCH 04/14] fixed bugs --- position.h | 6 ++---- tests.cpp | 2 -- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/position.h b/position.h index 4fad49c..d7a3f95 100644 --- a/position.h +++ b/position.h @@ -193,9 +193,11 @@ template state_ = state(); history.pop_back(); + refresh_attacks(); return state_; } else { history.pop_back(); + refresh_attacks(); return; } } @@ -208,10 +210,6 @@ template (state().castlingRights & (state().turn == WHITE ? BLACK_CASTLING : WHITE_CASTLING)); - state().hash ^= zobrist::RandomCastle[state().castlingRights]; state().hash ^= zobrist::RandomTurn; state().fullMoveNumber += (state().turn == WHITE); state().pliesFromNull = state().repetition = 0; diff --git a/tests.cpp b/tests.cpp index 1032940..8b54947 100644 --- a/tests.cpp +++ b/tests.cpp @@ -206,8 +206,6 @@ template uint64_t perft(_Po pos.template legals(moves); if constexpr (EnableDiv) for (const Move &m : moves) { - pos.doNullMove(); - pos.undoMove(); std::cout << m << ": 1\n"; } return moves.size(); From dc8a2a64a4e9ccf71aa11dd1f5e44f981abd4982 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Thu, 30 Apr 2026 14:11:13 +0700 Subject: [PATCH 05/14] downgrade cmake req --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b1297bc..d32b317 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # -cmake_minimum_required(VERSION 3.16) +cmake_minimum_required(VERSION 3.110) project(chesslib LANGUAGES CXX) set(CMAKE_CXX_STANDARD 17) @@ -93,4 +93,4 @@ if(BUILD_TESTING) endif() endif() -endif() \ No newline at end of file +endif() From 83f92f668db380e8f6a60df322e8f5f47d3469ab Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Thu, 30 Apr 2026 14:12:32 +0700 Subject: [PATCH 06/14] downgrade cmake req --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d32b317..299835f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # -cmake_minimum_required(VERSION 3.110) +cmake_minimum_required(VERSION 3.10) project(chesslib LANGUAGES CXX) set(CMAKE_CXX_STANDARD 17) From 5f85509ebb4539136d60444c95734b66f9a59e25 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Thu, 30 Apr 2026 14:22:42 +0700 Subject: [PATCH 07/14] upgraded doctest --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 299835f..444c88a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,7 +68,7 @@ if(BUILD_TESTING) FetchContent_Declare( doctest GIT_REPOSITORY https://github.com/doctest/doctest.git - GIT_TAG v2.4.12 + GIT_TAG v2.5.2 ) FetchContent_MakeAvailable(doctest) From 5bed7c9b356e42517f46462883eb3cde45b3d0d9 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Thu, 30 Apr 2026 15:05:32 +0700 Subject: [PATCH 08/14] fixed tiny bugs, through hash consistiency is commented due to the amount of output printed --- CMakeLists.txt | 2 +- attacks.h | 35 ++++++++++++++++++++++++++++++++++- moves_io.cpp | 9 +++------ moves_io.h | 3 --- non_core_tests.cpp | 5 +++++ position.h | 2 +- tests.cpp | 26 ++++++++++++++++++++------ 7 files changed, 64 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 444c88a..1f9eebb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.14) project(chesslib LANGUAGES CXX) set(CMAKE_CXX_STANDARD 17) diff --git a/attacks.h b/attacks.h index 40d476b..fb90680 100644 --- a/attacks.h +++ b/attacks.h @@ -145,7 +145,7 @@ struct Magic { struct Magic { Bitboard mask; Bitboard magic; - int index; + size_t index; Bitboard shift; constexpr Bitboard operator()(Bitboard b) const { return (((b & mask)) * magic) >> shift; } }; @@ -181,6 +181,39 @@ extern const std::array BishopAttacks; return (b & ~MASK_FILE[7]) << 1; case Direction::SOUTH_EAST: return (b & ~MASK_FILE[7]) >> 7; + case DOUBLE_NORTH: + return b << 16; + + case DOUBLE_SOUTH: + return b >> 16; + + case DOUBLE_EAST: + return (b & ~MASK_FILE[7] & ~(MASK_FILE[7] >> 1)) << 2; + + case DOUBLE_WEST: + return (b & ~MASK_FILE[0] & ~(MASK_FILE[0] << 1)) >> 2; + + case DOUBLE_NORTH_EAST: { + Bitboard t = (b & ~MASK_FILE[7]) << 9; + return (t & ~MASK_FILE[7]) << 9; + } + + case DOUBLE_NORTH_WEST: { + Bitboard t = (b & ~MASK_FILE[0]) << 7; + return (t & ~MASK_FILE[0]) << 7; + } + + case DOUBLE_SOUTH_EAST: { + Bitboard t = (b & ~MASK_FILE[7]) >> 7; + return (t & ~MASK_FILE[7]) >> 7; + } + + case DOUBLE_SOUTH_WEST: { + Bitboard t = (b & ~MASK_FILE[0]) >> 9; + return (t & ~MASK_FILE[0]) >> 9; + } + case DIR_NONE: + return b; default: UNREACHABLE(); return 0; diff --git a/moves_io.cpp b/moves_io.cpp index 339bf8b..32412ff 100644 --- a/moves_io.cpp +++ b/moves_io.cpp @@ -19,15 +19,10 @@ // UCI moves parsing // License: https://github.com/Disservin/chess-library/blob/master/LICENSE -// pjpuzzler/cpp-chess doesn't have license, but it is linked to niklasf/python-chess - -// License: https://github.com/niklasf/python-chess/blob/master/LICENSE.txt #include "moves_io.h" #include "position.h" #include "types.h" #include -#include -#include #include #if defined(__EXCEPTIONS) #define THROW_IF_EXCEPTIONS_ON(stuff) throw stuff @@ -261,8 +256,10 @@ template Move parseSan(const _Position &pos, std: // consume it std::string src_sq_str = prefix.substr(prefix.size() - 2, 2); src_square = parse_square(src_sq_str); - if (src_square == SQ_NONE) + if (src_square == SQ_NONE){ THROW_IF_EXCEPTIONS_ON(IllegalMoveException("illegal san: '" + _san + "' in " + pos.fen())); + return Move::none(); + } prefix.resize(prefix.size() - 2); } } diff --git a/moves_io.h b/moves_io.h index 7afe49d..2a00591 100644 --- a/moves_io.h +++ b/moves_io.h @@ -16,9 +16,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -// pjpuzzler/cpp-chess doesn't have license, but it is linked to niklasf/python-chess - -// License: https://github.com/niklasf/python-chess/blob/master/LICENSE.txt #pragma once #include "fwd_decl.h" #include diff --git a/non_core_tests.cpp b/non_core_tests.cpp index 5a8ae98..c7bb8cb 100644 --- a/non_core_tests.cpp +++ b/non_core_tests.cpp @@ -440,6 +440,8 @@ TEST_SUITE("SAN Parser") { REQUIRE_THROWS_WITH_AS(uci::parseSan(b, "0-0+?!"), "illegal san: '0-0+?!' in rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQK2R w KQkq - 0 17", chess::uci::IllegalMoveException); +#else + REQUIRE(uci::parseSan(b, "0-0+?!") == Move::none()); #endif REQUIRE(uci::parseSan(b, "0-0+?!", true) == m); } @@ -453,7 +455,10 @@ TEST_SUITE("SAN Parser") { REQUIRE_THROWS_WITH_AS(uci::parseSan(b, "0-0-0+?!"), "illegal san: '0-0-0+?!' in rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/R3K2R w KQkq - 0 1", chess::uci::IllegalMoveException); +#else + REQUIRE(uci::parseSan(b, "0-0-0+?!") == Move::none()); #endif + REQUIRE(uci::parseSan(b, "0-0-0+?!", true) == m); } diff --git a/position.h b/position.h index d7a3f95..9d4371c 100644 --- a/position.h +++ b/position.h @@ -388,7 +388,7 @@ template #include -#include using namespace chess; // --------- Color assertions ---------- static_assert(color_of(PolyglotPiece::BPAWN) == BLACK, "BPAWN should be BLACK"); @@ -215,11 +213,27 @@ template uint64_t perft(_Po uint64_t total = 0; for (const Move &m : moves) { pos.template doMove(m); - pos.doNullMove(); - pos.undoMove(); + { + const auto pre_nm_hash_1 = pos.hash(); + const auto pre_nm_fen_1 = pos.fen(); + //REQUIRE(pos.zobrist() == pre_nm_hash_1); + pos.doNullMove(); + pos.undoMove(); + /*REQUIRE(pos.hash() == pre_nm_hash_1); + REQUIRE(pos.fen() == pre_nm_fen_1); + REQUIRE(pos.zobrist() == pre_nm_hash_1);*/ + } const uint64_t nodes = perft(pos, depth - 1); - pos.doNullMove(); - pos.undoMove(); + { + const auto pre_nm_hash_1 = pos.hash(); + const auto pre_nm_fen_1 = pos.fen(); + //REQUIRE(pos.zobrist() == pre_nm_hash_1); + pos.doNullMove(); + pos.undoMove(); + /*REQUIRE(pos.hash() == pre_nm_hash_1); + REQUIRE(pos.fen() == pre_nm_fen_1); + REQUIRE(pos.zobrist() == pre_nm_hash_1);*/ + } pos.undoMove(); if constexpr (EnableDiv) std::cout << m << ": " << nodes << '\n'; From 772987d3991ffc3bb8dc9824e59ef4ccad5b2a08 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Thu, 30 Apr 2026 08:06:07 +0000 Subject: [PATCH 09/14] Apply clang-format --- moves_io.cpp | 6 +++--- non_core_tests.cpp | 6 +++--- position.h | 2 +- tests.cpp | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/moves_io.cpp b/moves_io.cpp index 32412ff..f794881 100644 --- a/moves_io.cpp +++ b/moves_io.cpp @@ -256,10 +256,10 @@ template Move parseSan(const _Position &pos, std: // consume it std::string src_sq_str = prefix.substr(prefix.size() - 2, 2); src_square = parse_square(src_sq_str); - if (src_square == SQ_NONE){ + if (src_square == SQ_NONE) { THROW_IF_EXCEPTIONS_ON(IllegalMoveException("illegal san: '" + _san + "' in " + pos.fen())); - return Move::none(); - } + return Move::none(); + } prefix.resize(prefix.size() - 2); } } diff --git a/non_core_tests.cpp b/non_core_tests.cpp index c7bb8cb..06695b7 100644 --- a/non_core_tests.cpp +++ b/non_core_tests.cpp @@ -441,7 +441,7 @@ TEST_SUITE("SAN Parser") { "illegal san: '0-0+?!' in rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQK2R w KQkq - 0 17", chess::uci::IllegalMoveException); #else - REQUIRE(uci::parseSan(b, "0-0+?!") == Move::none()); + REQUIRE(uci::parseSan(b, "0-0+?!") == Move::none()); #endif REQUIRE(uci::parseSan(b, "0-0+?!", true) == m); } @@ -456,9 +456,9 @@ TEST_SUITE("SAN Parser") { "illegal san: '0-0-0+?!' in rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/R3K2R w KQkq - 0 1", chess::uci::IllegalMoveException); #else - REQUIRE(uci::parseSan(b, "0-0-0+?!") == Move::none()); + REQUIRE(uci::parseSan(b, "0-0-0+?!") == Move::none()); #endif - + REQUIRE(uci::parseSan(b, "0-0-0+?!", true) == m); } diff --git a/position.h b/position.h index 9d4371c..c879391 100644 --- a/position.h +++ b/position.h @@ -388,7 +388,7 @@ template uint64_t perft(_Po { const auto pre_nm_hash_1 = pos.hash(); const auto pre_nm_fen_1 = pos.fen(); - //REQUIRE(pos.zobrist() == pre_nm_hash_1); + // REQUIRE(pos.zobrist() == pre_nm_hash_1); pos.doNullMove(); pos.undoMove(); /*REQUIRE(pos.hash() == pre_nm_hash_1); @@ -227,7 +227,7 @@ template uint64_t perft(_Po { const auto pre_nm_hash_1 = pos.hash(); const auto pre_nm_fen_1 = pos.fen(); - //REQUIRE(pos.zobrist() == pre_nm_hash_1); + // REQUIRE(pos.zobrist() == pre_nm_hash_1); pos.doNullMove(); pos.undoMove(); /*REQUIRE(pos.hash() == pre_nm_hash_1); From e6dde5b1c5322ea8964b0fcdc3c1fa06c825dd3f Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Thu, 30 Apr 2026 15:24:10 +0700 Subject: [PATCH 10/14] Update tests.cpp --- tests.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests.cpp b/tests.cpp index 448dd1a..da37fe8 100644 --- a/tests.cpp +++ b/tests.cpp @@ -213,17 +213,20 @@ template uint64_t perft(_Po uint64_t total = 0; for (const Move &m : moves) { pos.template doMove(m); + #if !IS_RELEASE { const auto pre_nm_hash_1 = pos.hash(); const auto pre_nm_fen_1 = pos.fen(); - // REQUIRE(pos.zobrist() == pre_nm_hash_1); + REQUIRE(pos.zobrist() == pre_nm_hash_1); pos.doNullMove(); pos.undoMove(); - /*REQUIRE(pos.hash() == pre_nm_hash_1); + REQUIRE(pos.hash() == pre_nm_hash_1); REQUIRE(pos.fen() == pre_nm_fen_1); - REQUIRE(pos.zobrist() == pre_nm_hash_1);*/ + REQUIRE(pos.zobrist() == pre_nm_hash_1); } + #endif const uint64_t nodes = perft(pos, depth - 1); + #if IS_RELEASE { const auto pre_nm_hash_1 = pos.hash(); const auto pre_nm_fen_1 = pos.fen(); @@ -234,6 +237,7 @@ template uint64_t perft(_Po REQUIRE(pos.fen() == pre_nm_fen_1); REQUIRE(pos.zobrist() == pre_nm_hash_1);*/ } + #endif pos.undoMove(); if constexpr (EnableDiv) std::cout << m << ": " << nodes << '\n'; From 6de2004ef38d455671216101ca06e9d9cbe91dc1 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Thu, 30 Apr 2026 08:24:45 +0000 Subject: [PATCH 11/14] Apply clang-format --- tests.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests.cpp b/tests.cpp index da37fe8..a293283 100644 --- a/tests.cpp +++ b/tests.cpp @@ -213,7 +213,7 @@ template uint64_t perft(_Po uint64_t total = 0; for (const Move &m : moves) { pos.template doMove(m); - #if !IS_RELEASE +#if !IS_RELEASE { const auto pre_nm_hash_1 = pos.hash(); const auto pre_nm_fen_1 = pos.fen(); @@ -224,9 +224,9 @@ template uint64_t perft(_Po REQUIRE(pos.fen() == pre_nm_fen_1); REQUIRE(pos.zobrist() == pre_nm_hash_1); } - #endif +#endif const uint64_t nodes = perft(pos, depth - 1); - #if IS_RELEASE +#if IS_RELEASE { const auto pre_nm_hash_1 = pos.hash(); const auto pre_nm_fen_1 = pos.fen(); @@ -237,7 +237,7 @@ template uint64_t perft(_Po REQUIRE(pos.fen() == pre_nm_fen_1); REQUIRE(pos.zobrist() == pre_nm_hash_1);*/ } - #endif +#endif pos.undoMove(); if constexpr (EnableDiv) std::cout << m << ": " << nodes << '\n'; From b62046272a0ef5c89e03e143e926b11672fda314 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Thu, 30 Apr 2026 19:52:39 +0700 Subject: [PATCH 12/14] fixed SUCCESS spams --- tests.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/tests.cpp b/tests.cpp index a293283..1e8c612 100644 --- a/tests.cpp +++ b/tests.cpp @@ -217,25 +217,31 @@ template uint64_t perft(_Po { const auto pre_nm_hash_1 = pos.hash(); const auto pre_nm_fen_1 = pos.fen(); - REQUIRE(pos.zobrist() == pre_nm_hash_1); + if (pos.zobrist() != pos.hash()) + REQUIRE(pos.zobrist() == pos.hash()); pos.doNullMove(); pos.undoMove(); - REQUIRE(pos.hash() == pre_nm_hash_1); - REQUIRE(pos.fen() == pre_nm_fen_1); - REQUIRE(pos.zobrist() == pre_nm_hash_1); + if (!(pos.hash() == pre_nm_hash_1 || pos.fen() == pre_nm_fen_1 || pos.zobrist() == pre_nm_hash_1)) { + REQUIRE(pos.hash() == pre_nm_hash_1); + REQUIRE(pos.fen() == pre_nm_fen_1); + REQUIRE(pos.zobrist() == pre_nm_hash_1); + } } #endif const uint64_t nodes = perft(pos, depth - 1); -#if IS_RELEASE +#if !IS_RELEASE { const auto pre_nm_hash_1 = pos.hash(); const auto pre_nm_fen_1 = pos.fen(); - // REQUIRE(pos.zobrist() == pre_nm_hash_1); + if (pos.zobrist() != pos.hash()) + REQUIRE(pos.zobrist() == pos.hash()); pos.doNullMove(); pos.undoMove(); - /*REQUIRE(pos.hash() == pre_nm_hash_1); - REQUIRE(pos.fen() == pre_nm_fen_1); - REQUIRE(pos.zobrist() == pre_nm_hash_1);*/ + if (!(pos.hash() == pre_nm_hash_1 || pos.fen() == pre_nm_fen_1 || pos.zobrist() == pre_nm_hash_1)) { + REQUIRE(pos.hash() == pre_nm_hash_1); + REQUIRE(pos.fen() == pre_nm_fen_1); + REQUIRE(pos.zobrist() == pre_nm_hash_1); + } } #endif pos.undoMove(); From 2af68f53537d7e5da93e39155b6ce612f72ce813 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Thu, 30 Apr 2026 20:01:57 +0700 Subject: [PATCH 13/14] fixed regression and empty compile flags --- .github/workflows/try_compile.yml | 5 ----- tests.cpp | 4 ++-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/try_compile.yml b/.github/workflows/try_compile.yml index a1759f3..be6f456 100644 --- a/.github/workflows/try_compile.yml +++ b/.github/workflows/try_compile.yml @@ -49,15 +49,10 @@ jobs: - name: Configure CMake shell: bash run: | - CXX_FLAGS="" - LINK_FLAGS="" - cmake -B "${{ steps.vars.outputs.dir }}" \ -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \ -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \ -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ - -DCMAKE_CXX_FLAGS_DEBUG="$CXX_FLAGS" \ - -DCMAKE_EXE_LINKER_FLAGS="$LINK_FLAGS" \ -S "${{ github.workspace }}" - name: Build diff --git a/tests.cpp b/tests.cpp index 1e8c612..318e24b 100644 --- a/tests.cpp +++ b/tests.cpp @@ -221,7 +221,7 @@ template uint64_t perft(_Po REQUIRE(pos.zobrist() == pos.hash()); pos.doNullMove(); pos.undoMove(); - if (!(pos.hash() == pre_nm_hash_1 || pos.fen() == pre_nm_fen_1 || pos.zobrist() == pre_nm_hash_1)) { + if (!(pos.hash() == pre_nm_hash_1 && pos.fen() == pre_nm_fen_1 && pos.zobrist() == pre_nm_hash_1)) { REQUIRE(pos.hash() == pre_nm_hash_1); REQUIRE(pos.fen() == pre_nm_fen_1); REQUIRE(pos.zobrist() == pre_nm_hash_1); @@ -237,7 +237,7 @@ template uint64_t perft(_Po REQUIRE(pos.zobrist() == pos.hash()); pos.doNullMove(); pos.undoMove(); - if (!(pos.hash() == pre_nm_hash_1 || pos.fen() == pre_nm_fen_1 || pos.zobrist() == pre_nm_hash_1)) { + if (!(pos.hash() == pre_nm_hash_1 && pos.fen() == pre_nm_fen_1 && pos.zobrist() == pre_nm_hash_1)) { REQUIRE(pos.hash() == pre_nm_hash_1); REQUIRE(pos.fen() == pre_nm_fen_1); REQUIRE(pos.zobrist() == pre_nm_hash_1); From 42e89e0bb4e00b906983704766c613c74847c71e Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Fri, 1 May 2026 17:26:43 +0700 Subject: [PATCH 14/14] Update non_core_tests.cpp --- non_core_tests.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/non_core_tests.cpp b/non_core_tests.cpp index 06695b7..d1786cd 100644 --- a/non_core_tests.cpp +++ b/non_core_tests.cpp @@ -436,13 +436,11 @@ TEST_SUITE("SAN Parser") { auto b = Position{ "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQK2R w KQkq - 0 17" }; Move m = Move::make(Square::SQ_E1, Square::SQ_H1); -#if defined(_DEBUG) && !defined(NDEBUG) - REQUIRE_THROWS_WITH_AS(uci::parseSan(b, "0-0+?!"), + Move m2 = Move::none(); + REQUIRE_THROWS_WITH_AS(m2 = uci::parseSan(b, "0-0+?!"), "illegal san: '0-0+?!' in rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQK2R w KQkq - 0 17", chess::uci::IllegalMoveException); -#else - REQUIRE(uci::parseSan(b, "0-0+?!") == Move::none()); -#endif + REQUIRE(m2 == Move::none()); REQUIRE(uci::parseSan(b, "0-0+?!", true) == m); } @@ -451,13 +449,11 @@ TEST_SUITE("SAN Parser") { Move m = Move::make(Square::SQ_E1, Square::SQ_A1); -#if defined(_DEBUG) && !defined(NDEBUG) - REQUIRE_THROWS_WITH_AS(uci::parseSan(b, "0-0-0+?!"), + Move m2 = Move::none(); + REQUIRE_THROWS_WITH_AS(m2 = uci::parseSan(b, "0-0-0+?!"), "illegal san: '0-0-0+?!' in rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/R3K2R w KQkq - 0 1", chess::uci::IllegalMoveException); -#else - REQUIRE(uci::parseSan(b, "0-0-0+?!") == Move::none()); -#endif + REQUIRE(m2 == Move::none()); REQUIRE(uci::parseSan(b, "0-0-0+?!", true) == m); }