From 5dfb2d3c41d040b71b3bffe0fbf139ddf5b61f01 Mon Sep 17 00:00:00 2001 From: Giovanni Maria Manduca <425gioviok@gmail.com> Date: Mon, 2 Jun 2025 19:48:27 +0200 Subject: [PATCH 1/9] still not ready --- .clang-format | 14 ++++++-- .clang-tidy | 43 ++++++++++++++++++++++++ src/common.hpp | 39 +++++++++++----------- src/main.cpp | 3 +- src/move.hpp | 82 +++++++++++++++++++++++++--------------------- src/square.hpp | 14 ++++---- src/uci.cpp | 20 +++++------ src/uci.hpp | 10 +++--- src/util/types.hpp | 2 +- 9 files changed, 143 insertions(+), 84 deletions(-) create mode 100644 .clang-tidy diff --git a/.clang-format b/.clang-format index 952d7d90..94303eca 100644 --- a/.clang-format +++ b/.clang-format @@ -8,7 +8,10 @@ AlignTrailingComments: true AllowAllParametersOfDeclarationOnNextLine: true AllowShortCaseLabelsOnASingleLine: false AllowShortEnumsOnASingleLine: false -AllowShortIfStatementsOnASingleLine: false +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortLambdasOnASingleLine: None AlwaysBreakTemplateDeclarations: Yes BasedOnStyle: WebKit BitFieldColonSpacing: After @@ -18,8 +21,13 @@ BreakBeforeBraces: Custom BraceWrapping: AfterFunction: false AfterClass: false - AfterControlStatement: true + AfterControlStatement: Never BeforeElse: true + AfterEnum: false + AfterNamespace: false + AfterStruct: false + AfterUnion: false + BeforeCatch: false BreakBeforeTernaryOperators: true BreakConstructorInitializers: AfterColon BreakStringLiterals: false @@ -33,7 +41,7 @@ MaxEmptyLinesToKeep: 2 NamespaceIndentation: None PackConstructorInitializers: Never ReflowComments: false -SortIncludes: false +SortIncludes: Never SortUsingDeclarations: false SpaceAfterCStyleCast: true SpaceAfterTemplateKeyword: false diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 00000000..ea857c53 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,43 @@ +Checks: > + -*, + readability-identifier-naming, + modernize-use-nodiscard, + modernize-avoid-c-arrays, + modernize-use-nullptr, + modernize-deprecated-headers, + modernize-replace-auto-ptr, + modernize-use-default-member-init, + modernize-use-equals-default, + modernize-use-equals-delete, + modernize-return-braced-init-list, + modernize-use-using, + modernize-use-transparent-functors, + cppcoreguidelines-avoid-c-arrays, + cppcoreguidelines-pro-type-cstyle-cast + +WarningsAsErrors: '' + +CheckOptions: + # Function names: snake_case + - key: readability-identifier-naming.FunctionCase + value: lower_case + + # Variable names: camelCase + - key: readability-identifier-naming.VariableCase + value: camelBack + + # Constants: SCREAMING_SNAKE_CASE + - key: readability-identifier-naming.ConstantCase + value: UPPER_CASE + + # Enum constant values: PascalCase + - key: readability-identifier-naming.EnumConstantCase + value: CamelCase + + # Public data members: camelCase + - key: readability-identifier-naming.PublicMemberCase + value: camelBack + + # Private data members: camelCase + - key: readability-identifier-naming.PrivateMemberCase + value: camelBack \ No newline at end of file diff --git a/src/common.hpp b/src/common.hpp index a1548053..a6e8303a 100644 --- a/src/common.hpp +++ b/src/common.hpp @@ -3,39 +3,38 @@ namespace Clockwork { enum class Color { - white, - black -}; + White, + Black +}; enum class PieceType { - pawn, - knight, - bishop, - rook, - queen, - king, - empty, + Pawn, + Knight, + Bishop, + Rook, + Queen, + King, + Empty, }; constexpr char piece_char(PieceType piece) { using enum PieceType; - switch (piece) - { - case pawn : + switch (piece) { + case Pawn : return 'p'; - case knight : + case Knight : return 'n'; - case bishop : + case Bishop : return 'b'; - case rook : + case Rook : return 'r'; - case queen : + case Queen : return 'q'; - case king : + case King : return 'k'; - case empty : + case Empty : return '.'; } } -} \ No newline at end of file +} \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index b36647ed..db0fb4cc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,9 +6,10 @@ int main(int argc, char* argv[]) { UCI::UCIHandler uci; if (argc > 1) - uci.handleCommandLine(argc, argv); + uci.handle_command_line(argc, argv); else uci.loop(); return 0; } + \ No newline at end of file diff --git a/src/move.hpp b/src/move.hpp index 3f13ce75..036c0cf1 100644 --- a/src/move.hpp +++ b/src/move.hpp @@ -6,55 +6,64 @@ #include -namespace Clockwork { +namespace Clockwork { -static_assert(static_cast(PieceType::knight) == 1); +static_assert(static_cast(PieceType::Knight) == 1); enum class MoveFlags : u16 { - normal = 0b0000 << 12, - castle = 0b0001 << 12, - capture_bit = 0b0100 << 12, - en_passant = 0b0110 << 12, - promotion_bit = 0b1000 << 12, - promo_knight = (0b1000 | (static_cast(PieceType::knight) - 1)) << 12, - promo_bishop = (0b1000 | (static_cast(PieceType::bishop) - 1)) << 12, - promo_rook = (0b1000 | (static_cast(PieceType::rook) - 1)) << 12, - promo_queen = (0b1000 | (static_cast(PieceType::queen) - 1)) << 12, - promo_capture = 0b1100 << 12, - promo_knight_capture = (0b1100 | (static_cast(PieceType::knight) - 1)) << 12, - promo_bishop_capture = (0b1100 | (static_cast(PieceType::bishop) - 1)) << 12, - promo_rook_capture = (0b1100 | (static_cast(PieceType::rook) - 1)) << 12, - promo_queen_capture = (0b1100 | (static_cast(PieceType::queen) - 1)) << 12, + Normal = 0b0000 << 12, + Castle = 0b0001 << 12, + CaptureBit = 0b0100 << 12, + EnPassant = 0b0110 << 12, + PromotionBit = 0b1000 << 12, + PromoKnight = (0b1000 | (static_cast(PieceType::Knight) - 1)) << 12, + PromoBishop = (0b1000 | (static_cast(PieceType::Bishop) - 1)) << 12, + PromoRook = (0b1000 | (static_cast(PieceType::Rook) - 1)) << 12, + PromoQueen = (0b1000 | (static_cast(PieceType::Queen) - 1)) << 12, + PromoCapture = 0b1100 << 12, + PromoKnightCapture = (0b1100 | (static_cast(PieceType::Knight) - 1)) << 12, + PromoBishopCapture = (0b1100 | (static_cast(PieceType::Bishop) - 1)) << 12, + PromoRookCapture = (0b1100 | (static_cast(PieceType::Rook) - 1)) << 12, + PromoQueenCapture = (0b1100 | (static_cast(PieceType::Queen) - 1)) << 12, }; - + struct Move { u16 raw; - constexpr Move(Square from, Square to, MoveFlags flags = MoveFlags::normal) { + constexpr Move(Square from, Square to, MoveFlags flags = MoveFlags::Normal) { raw = from.raw | (to.raw << 6) | static_cast(flags); } - constexpr Square from() const { return Square(raw & 0x3F); } - - constexpr Square to() const { return Square((raw >> 6) & 0x3F); } + [[nodiscard]] constexpr Square from() const { + return {raw & 0x3F}; + } - constexpr MoveFlags flags() const { return MoveFlags{static_cast(raw & (0xF << 12))}; } + [[nodiscard]] constexpr Square to() const { + return {(raw >> 6) & 0x3F}; + } - constexpr bool is_capture() const { return raw & static_cast(MoveFlags::capture_bit); } + [[nodiscard]] constexpr MoveFlags flags() const { + return MoveFlags{static_cast(raw & (0xF << 12))}; + } - constexpr bool is_promotion() const { return raw & static_cast(MoveFlags::promotion_bit); } + [[nodiscard]] constexpr bool is_capture() const { + return raw & static_cast(MoveFlags::CaptureBit); + } - constexpr std::optional promo() const { - switch (flags()) - { - case MoveFlags::promo_knight : - return PieceType::knight; - case MoveFlags::promo_bishop : - return PieceType::bishop; - case MoveFlags::promo_rook : - return PieceType::rook; - case MoveFlags::promo_queen : - return PieceType::queen; + [[nodiscard]] constexpr bool is_promotion() const { + return raw & static_cast(MoveFlags::PromotionBit); + } + + [[nodiscard]] constexpr std::optional promo() const { + switch (flags()) { + case MoveFlags::PromoKnight : + return PieceType::Knight; + case MoveFlags::PromoBishop : + return PieceType::Bishop; + case MoveFlags::PromoRook : + return PieceType::Rook; + case MoveFlags::PromoQueen : + return PieceType::Queen; default : return std::nullopt; } @@ -62,8 +71,7 @@ struct Move { friend std::ostream& operator<<(std::ostream& os, Move mv) { os << mv.from() << mv.to(); - if (auto promo = mv.promo()) - { + if (auto promo = mv.promo()) { os << piece_char(*promo); } return os; diff --git a/src/square.hpp b/src/square.hpp index 21aa3536..8c86d224 100644 --- a/src/square.hpp +++ b/src/square.hpp @@ -10,12 +10,12 @@ namespace Clockwork { struct Square { - u8 raw; + u8 raw; constexpr Square(u8 r) : raw{r} {} - static constexpr Square fromFileAndRank(int file, int rank) { + static constexpr Square from_file_and_rank(int file, int rank) { assert(file >= 0 && file < 8); assert(rank >= 0 && rank < 8); return Square{static_cast(rank * 8 + file)}; @@ -26,16 +26,16 @@ struct Square { return std::nullopt; if (str[0] < 'a' or str[0] > 'h') return std::nullopt; - const int file = str[0] - 'a'; + const int FILE = str[0] - 'a'; if (str[1] < '1' or str[1] > '8') return std::nullopt; - const int rank = str[1] - '1'; - return fromFileAndRank(file, rank); + const int RANK = str[1] - '1'; + return from_file_and_rank(FILE, RANK); } - constexpr usize file() const { return raw % 8; } + [[nodiscard]] constexpr usize file() const { return raw % 8; } - constexpr usize rank() const { return raw / 8; } + [[nodiscard]] constexpr usize rank() const { return raw / 8; } friend std::ostream& operator<<(std::ostream& os, Square sq) { char file = static_cast('a' + sq.file()); diff --git a/src/uci.cpp b/src/uci.cpp index 4080e74c..2a96c5c8 100644 --- a/src/uci.cpp +++ b/src/uci.cpp @@ -6,22 +6,22 @@ #include #include #include - + namespace Clockwork::UCI { void UCIHandler::loop() { std::string input; - + while (std::getline(std::cin, input)) - executeCommand(input); + execute_command(input); } -void UCIHandler::handleCommandLine(int argc, char* argv[]) { +void UCIHandler::handle_command_line(int argc, char* argv[]) { for (int i = 1; i < argc; ++i) - executeCommand(argv[i]); + execute_command(argv[i]); } -void UCIHandler::executeCommand(const std::string& line) { +void UCIHandler::execute_command(const std::string& line) { std::istringstream is{line}; std::string command; @@ -37,14 +37,14 @@ void UCIHandler::executeCommand(const std::string& line) { else if (command == "quit") std::exit(0); else if (command == "go") - handleGo(is); + handle_go(is); else if (command == "position") - handlePosition(is); + handle_position(is); else std::cout << "Unknown command" << std::endl; } -void UCIHandler::handleGo(std::istringstream& is) { +void UCIHandler::handle_go(std::istringstream& is) { std::string token; while (is >> token) { @@ -75,7 +75,7 @@ void UCIHandler::handleGo(std::istringstream& is) { } } -void UCIHandler::handlePosition(std::istringstream& is) { +void UCIHandler::handle_position(std::istringstream& is) { std::string token; if (is >> token) { diff --git a/src/uci.hpp b/src/uci.hpp index 7945a4d9..7962d7a4 100644 --- a/src/uci.hpp +++ b/src/uci.hpp @@ -13,16 +13,16 @@ struct SearchSettings { int moveTime = 0; }; -class UCIHandler { +class UCIHandler { public: void loop(); - void handleCommandLine(int argc, char* argv[]); + void handle_command_line(int argc, char* argv[]); private: SearchSettings settings; - void executeCommand(const std::string&); - void handleGo(std::istringstream&); - void handlePosition(std::istringstream&); + void execute_command(const std::string&); + void handle_go(std::istringstream&); + void handle_position(std::istringstream&); }; } diff --git a/src/util/types.hpp b/src/util/types.hpp index 086e2937..49f5998b 100644 --- a/src/util/types.hpp +++ b/src/util/types.hpp @@ -11,7 +11,7 @@ using u8 = std::uint8_t; using u16 = std::uint16_t; using u32 = std::uint32_t; using u64 = std::uint64_t; -#pragma GCC diagnostic push +#pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpedantic" using u128 = unsigned __int128; #pragma GCC diagnostic pop From e72fe0f741bd91daf94c8f72e8923c45b201edcb Mon Sep 17 00:00:00 2001 From: Giovanni Maria Manduca <425gioviok@gmail.com> Date: Mon, 2 Jun 2025 19:49:52 +0200 Subject: [PATCH 2/9] clang-formatted --- src/common.hpp | 4 ++-- src/main.cpp | 1 - src/move.hpp | 26 +++++++++++++------------- src/square.hpp | 13 +++++++++---- src/uci.cpp | 39 +++++++++++++-------------------------- src/uci.hpp | 18 +++++++++--------- src/util/types.hpp | 2 +- 7 files changed, 47 insertions(+), 56 deletions(-) diff --git a/src/common.hpp b/src/common.hpp index a6e8303a..4c78ee1f 100644 --- a/src/common.hpp +++ b/src/common.hpp @@ -5,7 +5,7 @@ namespace Clockwork { enum class Color { White, Black -}; +}; enum class PieceType { Pawn, @@ -37,4 +37,4 @@ constexpr char piece_char(PieceType piece) { } } -} \ No newline at end of file +} \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index db0fb4cc..046f2049 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,4 +12,3 @@ int main(int argc, char* argv[]) { return 0; } - \ No newline at end of file diff --git a/src/move.hpp b/src/move.hpp index 036c0cf1..8ecc43a6 100644 --- a/src/move.hpp +++ b/src/move.hpp @@ -6,27 +6,27 @@ #include -namespace Clockwork { +namespace Clockwork { static_assert(static_cast(PieceType::Knight) == 1); enum class MoveFlags : u16 { - Normal = 0b0000 << 12, - Castle = 0b0001 << 12, - CaptureBit = 0b0100 << 12, - EnPassant = 0b0110 << 12, - PromotionBit = 0b1000 << 12, - PromoKnight = (0b1000 | (static_cast(PieceType::Knight) - 1)) << 12, - PromoBishop = (0b1000 | (static_cast(PieceType::Bishop) - 1)) << 12, - PromoRook = (0b1000 | (static_cast(PieceType::Rook) - 1)) << 12, - PromoQueen = (0b1000 | (static_cast(PieceType::Queen) - 1)) << 12, - PromoCapture = 0b1100 << 12, + Normal = 0b0000 << 12, + Castle = 0b0001 << 12, + CaptureBit = 0b0100 << 12, + EnPassant = 0b0110 << 12, + PromotionBit = 0b1000 << 12, + PromoKnight = (0b1000 | (static_cast(PieceType::Knight) - 1)) << 12, + PromoBishop = (0b1000 | (static_cast(PieceType::Bishop) - 1)) << 12, + PromoRook = (0b1000 | (static_cast(PieceType::Rook) - 1)) << 12, + PromoQueen = (0b1000 | (static_cast(PieceType::Queen) - 1)) << 12, + PromoCapture = 0b1100 << 12, PromoKnightCapture = (0b1100 | (static_cast(PieceType::Knight) - 1)) << 12, PromoBishopCapture = (0b1100 | (static_cast(PieceType::Bishop) - 1)) << 12, PromoRookCapture = (0b1100 | (static_cast(PieceType::Rook) - 1)) << 12, PromoQueenCapture = (0b1100 | (static_cast(PieceType::Queen) - 1)) << 12, }; - + struct Move { u16 raw; @@ -53,7 +53,7 @@ struct Move { [[nodiscard]] constexpr bool is_promotion() const { return raw & static_cast(MoveFlags::PromotionBit); } - + [[nodiscard]] constexpr std::optional promo() const { switch (flags()) { case MoveFlags::PromoKnight : diff --git a/src/square.hpp b/src/square.hpp index 8c86d224..c8ca68f3 100644 --- a/src/square.hpp +++ b/src/square.hpp @@ -10,10 +10,11 @@ namespace Clockwork { struct Square { - u8 raw; + u8 raw; constexpr Square(u8 r) : - raw{r} {} + raw{r} { + } static constexpr Square from_file_and_rank(int file, int rank) { assert(file >= 0 && file < 8); @@ -33,9 +34,13 @@ struct Square { return from_file_and_rank(FILE, RANK); } - [[nodiscard]] constexpr usize file() const { return raw % 8; } + [[nodiscard]] constexpr usize file() const { + return raw % 8; + } - [[nodiscard]] constexpr usize rank() const { return raw / 8; } + [[nodiscard]] constexpr usize rank() const { + return raw / 8; + } friend std::ostream& operator<<(std::ostream& os, Square sq) { char file = static_cast('a' + sq.file()); diff --git a/src/uci.cpp b/src/uci.cpp index 2a96c5c8..10f01df0 100644 --- a/src/uci.cpp +++ b/src/uci.cpp @@ -6,12 +6,12 @@ #include #include #include - + namespace Clockwork::UCI { void UCIHandler::loop() { std::string input; - + while (std::getline(std::cin, input)) execute_command(input); } @@ -27,8 +27,7 @@ void UCIHandler::execute_command(const std::string& line) { std::string command; is >> std::skipws >> command; - if (command == "uci") - { + if (command == "uci") { std::cout << "id Name Clockwork\n"; std::cout << "id author The Clockwork community" << std::endl; } @@ -46,30 +45,23 @@ void UCIHandler::execute_command(const std::string& line) { void UCIHandler::handle_go(std::istringstream& is) { std::string token; - while (is >> token) - { - if (token == "depth") - { + while (is >> token) { + if (token == "depth") { is >> settings.depth; } - else if (token == "movetime") - { + else if (token == "movetime") { is >> settings.moveTime; } - else if (token == "wtime") - { + else if (token == "wtime") { is >> settings.wTime; } - else if (token == "btime") - { + else if (token == "btime") { is >> settings.bTime; } - else if (token == "winc") - { + else if (token == "winc") { is >> settings.wInc; } - else if (token == "binc") - { + else if (token == "binc") { is >> settings.bInc; } } @@ -77,14 +69,9 @@ void UCIHandler::handle_go(std::istringstream& is) { void UCIHandler::handle_position(std::istringstream& is) { std::string token; - if (is >> token) - { - if (token == "startpos") - { - } - else if (token == "fen") - { - } + if (is >> token) { + if (token == "startpos") {} + else if (token == "fen") {} } } diff --git a/src/uci.hpp b/src/uci.hpp index 7962d7a4..e8511e7a 100644 --- a/src/uci.hpp +++ b/src/uci.hpp @@ -5,24 +5,24 @@ namespace Clockwork::UCI { struct SearchSettings { - int depth = 0; - int wTime = 0; - int bTime = 0; - int wInc = 0; - int bInc = 0; + int depth = 0; + int wTime = 0; + int bTime = 0; + int wInc = 0; + int bInc = 0; int moveTime = 0; }; -class UCIHandler { +class UCIHandler { public: void loop(); void handle_command_line(int argc, char* argv[]); private: SearchSettings settings; - void execute_command(const std::string&); - void handle_go(std::istringstream&); - void handle_position(std::istringstream&); + void execute_command(const std::string&); + void handle_go(std::istringstream&); + void handle_position(std::istringstream&); }; } diff --git a/src/util/types.hpp b/src/util/types.hpp index 49f5998b..086e2937 100644 --- a/src/util/types.hpp +++ b/src/util/types.hpp @@ -11,7 +11,7 @@ using u8 = std::uint8_t; using u16 = std::uint16_t; using u32 = std::uint32_t; using u64 = std::uint64_t; -#pragma GCC diagnostic push +#pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpedantic" using u128 = unsigned __int128; #pragma GCC diagnostic pop From bfc0a74b352011101bfc4391b2ece88e7c0adde1 Mon Sep 17 00:00:00 2001 From: Giovanni Maria Manduca <425gioviok@gmail.com> Date: Mon, 2 Jun 2025 19:52:23 +0200 Subject: [PATCH 3/9] static_cast down u16 to square for from() and to() getters --- src/move.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/move.hpp b/src/move.hpp index 8ecc43a6..34dd3411 100644 --- a/src/move.hpp +++ b/src/move.hpp @@ -35,11 +35,11 @@ struct Move { } [[nodiscard]] constexpr Square from() const { - return {raw & 0x3F}; + return static_cast(raw & 0x3F); } - + [[nodiscard]] constexpr Square to() const { - return {(raw >> 6) & 0x3F}; + return static_cast((raw >> 6) & 0x3F); } [[nodiscard]] constexpr MoveFlags flags() const { From bf1af1e80f290576b31956ae88c8acf1b82b051a Mon Sep 17 00:00:00 2001 From: Giovanni Maria Manduca <425gioviok@gmail.com> Date: Tue, 3 Jun 2025 03:27:19 +0200 Subject: [PATCH 4/9] follow community class indentation guidelines --- .clang-format | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.clang-format b/.clang-format index 94303eca..8a62dc29 100644 --- a/.clang-format +++ b/.clang-format @@ -1,4 +1,4 @@ -AccessModifierOffset: -1 +AccessModifierOffset: 0 AlignAfterOpenBracket: Align AlignConsecutiveAssignments: Consecutive AlignConsecutiveDeclarations: Consecutive From 016a110861a935c3e084eadc99f3b460749fdc92 Mon Sep 17 00:00:00 2001 From: Giovanni Maria Manduca <425gioviok@gmail.com> Date: Tue, 3 Jun 2025 03:27:31 +0200 Subject: [PATCH 5/9] follow latest community guidelines --- .clang-tidy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index ea857c53..6860ba8a 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -24,7 +24,7 @@ CheckOptions: # Variable names: camelCase - key: readability-identifier-naming.VariableCase - value: camelBack + value: lower_case # Constants: SCREAMING_SNAKE_CASE - key: readability-identifier-naming.ConstantCase @@ -36,8 +36,8 @@ CheckOptions: # Public data members: camelCase - key: readability-identifier-naming.PublicMemberCase - value: camelBack + value: lower_case # Private data members: camelCase - key: readability-identifier-naming.PrivateMemberCase - value: camelBack \ No newline at end of file + value: lower_case \ No newline at end of file From e5154e6820d7b9df0c8eddf39a06dea99573f558 Mon Sep 17 00:00:00 2001 From: Giovanni Maria Manduca <425gioviok@gmail.com> Date: Tue, 3 Jun 2025 03:27:53 +0200 Subject: [PATCH 6/9] update to latest communitu guidelines --- src/uci.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/uci.hpp b/src/uci.hpp index e8511e7a..761a4dbe 100644 --- a/src/uci.hpp +++ b/src/uci.hpp @@ -6,11 +6,11 @@ namespace Clockwork::UCI { struct SearchSettings { int depth = 0; - int wTime = 0; - int bTime = 0; - int wInc = 0; - int bInc = 0; - int moveTime = 0; + int w_time = 0; + int b_time = 0; + int w_inc = 0; + int b_inc = 0; + int move_time = 0; }; class UCIHandler { From c7bd6dcec33fcb41ee3b0aa3cab80642b0b6df75 Mon Sep 17 00:00:00 2001 From: Giovanni Maria Manduca <425gioviok@gmail.com> Date: Tue, 3 Jun 2025 03:30:06 +0200 Subject: [PATCH 7/9] rerun clang-format --- src/move.hpp | 2 +- src/uci.hpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/move.hpp b/src/move.hpp index 34dd3411..68f2b514 100644 --- a/src/move.hpp +++ b/src/move.hpp @@ -37,7 +37,7 @@ struct Move { [[nodiscard]] constexpr Square from() const { return static_cast(raw & 0x3F); } - + [[nodiscard]] constexpr Square to() const { return static_cast((raw >> 6) & 0x3F); } diff --git a/src/uci.hpp b/src/uci.hpp index 761a4dbe..566b98a5 100644 --- a/src/uci.hpp +++ b/src/uci.hpp @@ -5,7 +5,7 @@ namespace Clockwork::UCI { struct SearchSettings { - int depth = 0; + int depth = 0; int w_time = 0; int b_time = 0; int w_inc = 0; @@ -14,11 +14,11 @@ struct SearchSettings { }; class UCIHandler { - public: + public: void loop(); void handle_command_line(int argc, char* argv[]); - private: + private: SearchSettings settings; void execute_command(const std::string&); void handle_go(std::istringstream&); From 59dbe8b0c0695f3f28c4f1cb712fd55be6a7d6e5 Mon Sep 17 00:00:00 2001 From: Giovanni Maria Manduca <425gioviok@gmail.com> Date: Tue, 3 Jun 2025 03:31:32 +0200 Subject: [PATCH 8/9] funny --- src/uci.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/uci.cpp b/src/uci.cpp index 10f01df0..158e0297 100644 --- a/src/uci.cpp +++ b/src/uci.cpp @@ -50,19 +50,19 @@ void UCIHandler::handle_go(std::istringstream& is) { is >> settings.depth; } else if (token == "movetime") { - is >> settings.moveTime; + is >> settings.move_time; } else if (token == "wtime") { - is >> settings.wTime; + is >> settings.w_time; } else if (token == "btime") { - is >> settings.bTime; + is >> settings.b_time; } else if (token == "winc") { - is >> settings.wInc; + is >> settings.w_inc; } else if (token == "binc") { - is >> settings.bInc; + is >> settings.b_inc; } } } From 85764687d3ea510500d1f6cec624e78305d9e394 Mon Sep 17 00:00:00 2001 From: Giovanni Maria Manduca <425gioviok@gmail.com> Date: Tue, 3 Jun 2025 03:32:36 +0200 Subject: [PATCH 9/9] Update clang tidy comment to match current preset --- .clang-tidy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 6860ba8a..93a938ee 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -22,7 +22,7 @@ CheckOptions: - key: readability-identifier-naming.FunctionCase value: lower_case - # Variable names: camelCase + # Variable names: snake_case - key: readability-identifier-naming.VariableCase value: lower_case @@ -34,10 +34,10 @@ CheckOptions: - key: readability-identifier-naming.EnumConstantCase value: CamelCase - # Public data members: camelCase + # Public data members: snake_case - key: readability-identifier-naming.PublicMemberCase value: lower_case - # Private data members: camelCase + # Private data members: snake_case - key: readability-identifier-naming.PrivateMemberCase value: lower_case \ No newline at end of file