From 430eb1a1ca37d7993ee63e6ab9e69694ec4b9338 Mon Sep 17 00:00:00 2001 From: Alexander Kurbatov Date: Wed, 16 Sep 2026 13:10:09 +0300 Subject: [PATCH 1/9] fix: Set path to cmake modules using PROJECT_SOURCE_DIR Signed-off-by: Alexander Kurbatov --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c8907d..a9c1ee9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,7 @@ if (MSVC) set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$:Debug>) endif () -list(APPEND CMAKE_MODULE_PATH thirdparty/cmake) +list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/thirdparty/cmake") # cpp-sc2 dependency include(cpp_sc2) From 85c9a8e3e05c37380a53b6a01ad9e5195868c6b0 Mon Sep 17 00:00:00 2001 From: Alexander Kurbatov Date: Wed, 16 Sep 2026 13:12:46 +0300 Subject: [PATCH 2/9] build: Switch to C++20 to follow the latest cpp-sc2 Signed-off-by: Alexander Kurbatov --- CMakeLists.txt | 4 ++-- thirdparty/cmake/cpp_sc2.cmake | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a9c1ee9..879cd53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,8 +24,8 @@ set(FETCHCONTENT_QUIET FALSE) option(BUILD_FOR_LADDER "Create build for the AIArena ladder" OFF) -# Build with c++17 support, required by sc2api -set(CMAKE_CXX_STANDARD 17) +# Build with c++20 support, required by sc2api +set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) # Specify output directories diff --git a/thirdparty/cmake/cpp_sc2.cmake b/thirdparty/cmake/cpp_sc2.cmake index 0a3e1e4..b401aba 100644 --- a/thirdparty/cmake/cpp_sc2.cmake +++ b/thirdparty/cmake/cpp_sc2.cmake @@ -12,7 +12,7 @@ set(BUILD_SC2_RENDERER OFF CACHE INTERNAL "" FORCE) FetchContent_Declare( cpp_sc2 GIT_REPOSITORY https://github.com/cpp-sc2/cpp-sc2.git - GIT_TAG v2.0.0 + GIT_TAG 6d0c5fac18d35d15e4beb100b700ba845d4a1616 GIT_PROGRESS TRUE ) FetchContent_MakeAvailable(cpp_sc2) From a095b55fa9715b2a6872629c9a53ee96d5780726 Mon Sep 17 00:00:00 2001 From: Alexander Kurbatov Date: Wed, 16 Sep 2026 13:14:10 +0300 Subject: [PATCH 3/9] chore: Bump copyright Signed-off-by: Alexander Kurbatov --- CMakeLists.txt | 2 +- LICENSE | 2 +- README.md | 2 +- src/Bot.cpp | 2 +- src/Bot.h | 2 +- src/CMakeLists.txt | 2 +- src/main.cpp | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 879cd53..504d33b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ # The MIT License (MIT) # -# Copyright (c) 2021-2024 Alexander Kurbatov +# Copyright (c) 2021-2026 Alexander Kurbatov cmake_minimum_required(VERSION 3.15) diff --git a/LICENSE b/LICENSE index ebc1ab9..9a230a6 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021-2024 Alexander Kurbatov +Copyright (c) 2021-2026 Alexander Kurbatov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 5144f6a..7629861 100644 --- a/README.md +++ b/README.md @@ -204,6 +204,6 @@ cmake --build build --parallel $(nproc --ignore=1) ``` ## License -Copyright (c) 2021-2024 Alexander Kurbatov +Copyright (c) 2021-2026 Alexander Kurbatov Licensed under the [MIT license](LICENSE). diff --git a/src/Bot.cpp b/src/Bot.cpp index 3e7a702..49ae303 100644 --- a/src/Bot.cpp +++ b/src/Bot.cpp @@ -1,6 +1,6 @@ // The MIT License (MIT) // -// Copyright (c) 2021-2024 Alexander Kurbatov +// Copyright (c) 2021-2026 Alexander Kurbatov #include "Bot.h" diff --git a/src/Bot.h b/src/Bot.h index 429c739..31edaf8 100644 --- a/src/Bot.h +++ b/src/Bot.h @@ -1,6 +1,6 @@ // The MIT License (MIT) // -// Copyright (c) 2021-2024 Alexander Kurbatov +// Copyright (c) 2021-2026 Alexander Kurbatov #pragma once diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 324afda..9d70d47 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,6 @@ # The MIT License (MIT) # -# Copyright (c) 2021-2024 Alexander Kurbatov +# Copyright (c) 2021-2026 Alexander Kurbatov set(bot_sources main.cpp diff --git a/src/main.cpp b/src/main.cpp index 1e38c7d..9c24015 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,6 @@ // The MIT License (MIT) // -// Copyright (c) 2021-2024 Alexander Kurbatov +// Copyright (c) 2021-2026 Alexander Kurbatov #include "Bot.h" From b0a8ab5829e3907a4cb07170c753321c4be5913c Mon Sep 17 00:00:00 2001 From: Alexander Kurbatov Date: Wed, 16 Sep 2026 13:20:29 +0300 Subject: [PATCH 4/9] docs: Correct version check command Signed-off-by: Alexander Kurbatov --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7629861..a023ef4 100644 --- a/README.md +++ b/README.md @@ -152,7 +152,7 @@ Cross compiling for Windows under WSL2 is supported through `cpp-sc2`. See the ` ### Game client version By default, the API assumes the latest version of the game client. The assumed version can be found in cmake's output, e.g.: ```bash -$ cmake -B build grep 'SC2 version' +$ cmake -B build | grep "SC2 version" Target SC2 version: 5.0.5 ... ``` From d672c4539edf98772efa2c2d06f20c2d3b9d9880 Mon Sep 17 00:00:00 2001 From: Alexander Kurbatov Date: Wed, 16 Sep 2026 13:23:42 +0300 Subject: [PATCH 5/9] chore: Update github actions Signed-off-by: Alexander Kurbatov --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 28c2d16..d9db10f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: os: [windows-latest, macos-latest, ubuntu-latest] steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v7.0.1 with: submodules: recursive @@ -32,13 +32,13 @@ jobs: run: cmake -B ${{env.BUILD_DIR}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - name: Build - run: cmake --build ${{env.BUILD_DIR}} --config ${{env.BUILD_TYPE}} --parallel 2 + run: cmake --build ${{env.BUILD_DIR}} --config ${{env.BUILD_TYPE}} --parallel ladder_build: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v7.0.1 with: submodules: recursive @@ -46,4 +46,4 @@ jobs: run: cmake -B ${{env.BUILD_DIR}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_FOR_LADDER=ON -DSC2_VERSION=4.10.0 - name: Build - run: cmake --build ${{env.BUILD_DIR}} --config ${{env.BUILD_TYPE}} --parallel 2 + run: cmake --build ${{env.BUILD_DIR}} --config ${{env.BUILD_TYPE}} --parallel From 6b18754c7aac6d784504edec90e5a3f05e1ef4c6 Mon Sep 17 00:00:00 2001 From: Alexander Kurbatov Date: Wed, 16 Sep 2026 16:02:34 +0300 Subject: [PATCH 6/9] feat: Modernize the sources - Use modern C++ style. - Apply std::format as C++20 allows it. - Provide some code formatting defaults. - Provide tidy preset. Signed-off-by: Alexander Kurbatov --- .clang-format | 27 +++++++++ .clang-tidy | 45 +++++++++++++++ README.md | 4 +- src/Bot.cpp | 55 +++++++++--------- src/Bot.h | 28 +++++----- src/main.cpp | 152 ++++++++++++++++++++++++++++++++------------------ 6 files changed, 215 insertions(+), 96 deletions(-) create mode 100644 .clang-format create mode 100644 .clang-tidy diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..1d48e40 --- /dev/null +++ b/.clang-format @@ -0,0 +1,27 @@ +--- +Language: Cpp +BasedOnStyle: Google +BreakBeforeBraces: Linux +ColumnLimit: 120 +IndentWidth: 4 +AccessModifierOffset: -4 +AllowShortBlocksOnASingleLine: Empty +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: Empty +AllowShortLoopsOnASingleLine: false +DerivePointerAlignment: false +IndentCaseLabels: false +InsertNewlineAtEOF: true +LineEnding: LF +PointerAlignment: Left +SpacesBeforeTrailingComments: 1 +Standard: Latest +--- +Language: Proto +DisableFormat: true +--- +Language: Json +BasedOnStyle: Google +ColumnLimit: 120 +IndentWidth: 2 diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000..8d44cb1 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,45 @@ +--- +Checks: "*, + -abseil-*, + -altera-*, + -android-*, + -boost-*, + -cert-*, + -cppcoreguidelines-pro-bounds-pointer-arithmetic, + -fuchsia-*, + -google-*, + -hicpp-*, + -linuxkernel-*, + -llvm-*, + -llvmlibc-*, + -mpi-*, + -objc-*, + -openmp-*, + -portability-avoid-pragma-once, + -readability-identifier-length, + -zircon-*, + cert-dcl50-cpp, + cert-dcl58-cpp, + cert-env33-c, + cert-err33-c, + cert-err34-c, + cert-err52-cpp, + cert-err58-cpp, + cert-err60-cpp, + cert-flp30-c, + cert-mem57-cpp, + cert-msc50-cpp, + cert-msc51-cpp, + cert-oop57-cpp, + cert-oop58-cpp, + google-build-namespaces, + google-readability-casting, + llvm-namespace-comment +" +CheckOptions: + misc-include-cleaner.IgnoreHeaders: 'sc2api/sc2_typeenums.h;sc2api/typeids/.*' + readability-function-cognitive-complexity.DescribeBasicIncrements: false +ExcludeHeaderFilterRegex: '.*/_deps/.*' +FormatStyle: none +HeaderFilterRegex: '.*/src/.*' +WarningsAsErrors: '*' diff --git a/README.md b/README.md index a023ef4..cb663ef 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,9 @@ Starter bot for StarCraft II with integrated cpp-sc2. ## Support -Feel free to post questions on the unofficial StarCraft II AI Discord server. [Invite Link](https://discordapp.com/invite/Emm5Ztz) +If you have any questions, feel free to send a message over the +[#cpp](https://discord.com/channels/350289306763657218/350289506068463618) +channel of the [AI Arena](https://discord.gg/YurYAgHRSw) Discord server. ## Build instructions diff --git a/src/Bot.cpp b/src/Bot.cpp index 49ae303..526da1f 100644 --- a/src/Bot.cpp +++ b/src/Bot.cpp @@ -4,63 +4,62 @@ #include "Bot.h" -#include +#include +#include #include #include +#include +#include -void Bot::OnGameStart() +auto Bot::OnGameStart() -> void { - std::cout << "New game started!" << std::endl; + std::cout << "New game started!\n"; } -void Bot::OnGameEnd() +auto Bot::OnGameEnd() -> void { - std::cout << "Game over!" << std::endl; + std::cout << "Game over!\n"; } -void Bot::OnBuildingConstructionComplete(const sc2::Unit* building_) +auto Bot::OnBuildingConstructionComplete(const sc2::Unit* building) -> void { - std::cout << sc2::UnitTypeToName(building_->unit_type) << - "(" << building_->tag << ") constructed" << std::endl; + std::cout << sc2::UnitTypeToName(building->unit_type) << " (" << building->tag << ") constructed\n"; } -void Bot::OnStep() +auto Bot::OnStep() -> void { - std::cout << "OnStep" << std::endl; + std::cout << "OnStep\n"; } -void Bot::OnUnitCreated(const sc2::Unit* unit_) +auto Bot::OnUnitCreated(const sc2::Unit* unit) -> void { - std::cout << sc2::UnitTypeToName(unit_->unit_type) << - "(" << unit_->tag << ") was created" << std::endl; + std::cout << sc2::UnitTypeToName(unit->unit_type) << " (" << unit->tag << ") was created\n"; } -void Bot::OnUnitIdle(const sc2::Unit* unit_) +auto Bot::OnUnitIdle(const sc2::Unit* unit) -> void { - std::cout << sc2::UnitTypeToName(unit_->unit_type) << - "(" << unit_->tag << ") is idle" << std::endl; + std::cout << sc2::UnitTypeToName(unit->unit_type) << " (" << unit->tag << ") is idle\n"; } -void Bot::OnUnitDestroyed(const sc2::Unit* unit_) +auto Bot::OnUnitDestroyed(const sc2::Unit* unit) -> void { - std::cout << sc2::UnitTypeToName(unit_->unit_type) << - "(" << unit_->tag << ") was destroyed" << std::endl; + std::cout << sc2::UnitTypeToName(unit->unit_type) << " (" << unit->tag << ") was destroyed\n"; } -void Bot::OnUpgradeCompleted(sc2::UpgradeID id_) +auto Bot::OnUpgradeCompleted(sc2::UpgradeID id) -> void { - std::cout << sc2::UpgradeIDToName(id_) << " completed" << std::endl; + std::cout << sc2::UpgradeIDToName(id) << " completed\n"; } -void Bot::OnError(const std::vector& client_errors, - const std::vector& protocol_errors) +auto Bot::OnError(const std::vector& client_errors, const std::vector& protocol_errors) + -> void { - for (const auto i : client_errors) { - std::cerr << "Encountered client error: " << - static_cast(i) << std::endl; + for (const auto& err : client_errors) { + std::cerr << "Encountered client error: " << static_cast(err) << '\n'; } - for (const auto& i : protocol_errors) - std::cerr << "Encountered protocol error: " << i << std::endl; + for (const auto& i : protocol_errors) { + std::cerr << "Encountered protocol error: " << i << '\n'; + } } diff --git a/src/Bot.h b/src/Bot.h index 31edaf8..fecea6f 100644 --- a/src/Bot.h +++ b/src/Bot.h @@ -5,29 +5,31 @@ #pragma once #include +#include + +#include +#include // The main bot class. -struct Bot: sc2::Agent -{ +struct Bot final : sc2::Agent { Bot() = default; - private: - void OnGameStart() final; + auto OnGameStart() -> void final; - void OnGameEnd() final; + auto OnGameEnd() -> void final; - void OnStep() final; + auto OnStep() -> void final; - void OnBuildingConstructionComplete(const sc2::Unit* building_) final; + auto OnBuildingConstructionComplete(const sc2::Unit* building) -> void final; - void OnUnitCreated(const sc2::Unit* unit_) final; + auto OnUnitCreated(const sc2::Unit* unit) -> void final; - void OnUnitIdle(const sc2::Unit* unit_) final; + auto OnUnitIdle(const sc2::Unit* unit) -> void final; - void OnUnitDestroyed(const sc2::Unit* unit_) final; + auto OnUnitDestroyed(const sc2::Unit* unit) -> void final; - void OnUpgradeCompleted(sc2::UpgradeID id_) final; + auto OnUpgradeCompleted(sc2::UpgradeID id) -> void final; - void OnError(const std::vector& client_errors, - const std::vector& protocol_errors = {}) final; + auto OnError(const std::vector& client_errors, + const std::vector& protocol_errors = {}) -> void final; }; diff --git a/src/main.cpp b/src/main.cpp index 9c24015..c330e4f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,96 +2,141 @@ // // Copyright (c) 2021-2026 Alexander Kurbatov -#include "Bot.h" - #include #include -#include +#include #include +#include "Bot.h" + #ifdef BUILD_FOR_LADDER +#include + +#include +#include +#include +#include +#include +#include + namespace { -struct Options -{ - Options(): GamePort(0), StartPort(0) - {} +constexpr int32_t ResponseTimeoutMS = 10000; - int32_t GamePort; - int32_t StartPort; +struct Options { + int32_t GamePort = 0; + int32_t StartPort = 0; std::string ServerAddress; std::string OpponentId; }; -void ParseArguments(int argc, char* argv[], Options* options_) +auto ParseInt(std::string_view value, int32_t& dst) -> bool +{ + const char* const first = value.data(); + const char* const last = first + value.size(); + const auto [ptr, ec] = std::from_chars(first, last, dst); + + return ec == std::errc{} && ptr == last; +} + +auto ParseArguments(int argc, char** argv) -> Options { + Options options; + sc2::ArgParser arg_parser(argv[0]); - arg_parser.AddOptions( + arg_parser.AddOptions({ + { + .abbreviation_ = "-g", + .fullname_ = "--GamePort", + .description_ = "Port of client to connect to", + .required_ = false, + }, + { + .abbreviation_ = "-o", + .fullname_ = "--StartPort", + .description_ = "Starting server port", + .required_ = false, + }, { - {"-g", "--GamePort", "Port of client to connect to", false}, - {"-o", "--StartPort", "Starting server port", false}, - {"-l", "--LadderServer", "Ladder server address", false}, - {"-x", "--OpponentId", "PlayerId of opponent", false}, - }); + .abbreviation_ = "-l", + .fullname_ = "--LadderServer", + .description_ = "Ladder server address", + .required_ = false, + }, + { + .abbreviation_ = "-x", + .fullname_ = "--OpponentId", + .description_ = "PlayerId of opponent", + .required_ = false, + }, + }); arg_parser.Parse(argc, argv); std::string GamePortStr; - if (arg_parser.Get("GamePort", GamePortStr)) - options_->GamePort = atoi(GamePortStr.c_str()); + if (arg_parser.Get("GamePort", GamePortStr) && !ParseInt(GamePortStr, options.GamePort)) { + std::cerr << "Invalid game port: " << GamePortStr << '\n'; + } std::string StartPortStr; - if (arg_parser.Get("StartPort", StartPortStr)) - options_->StartPort = atoi(StartPortStr.c_str()); + if (arg_parser.Get("StartPort", StartPortStr) && !ParseInt(StartPortStr, options.StartPort)) { + std::cerr << "Invalid start port: " << StartPortStr << '\n'; + } std::string OpponentId; - if (arg_parser.Get("OpponentId", OpponentId)) - options_->OpponentId = OpponentId; + if (arg_parser.Get("OpponentId", OpponentId)) { + options.OpponentId = OpponentId; + } + + arg_parser.Get("LadderServer", options.ServerAddress); - arg_parser.Get("LadderServer", options_->ServerAddress); + return options; } -} // namespace +} // namespace -int main(int argc, char* argv[]) -{ - Options options; - ParseArguments(argc, argv, &options); +auto main(int argc, char* argv[]) -> int +try { + auto options = ParseArguments(argc, argv); sc2::Coordinator coordinator; Bot bot; - size_t num_agents = 2; - coordinator.SetParticipants({ CreateParticipant(sc2::Race::Random, &bot, "BlankBot") }); + const size_t num_agents = 2; + coordinator.SetParticipants({CreateParticipant(sc2::Race::Random, &bot, "BlankBot")}); - std::cout << "Connecting to port " << options.GamePort << std::endl; + std::cout << "Connecting to port " << options.GamePort << '\n'; coordinator.Connect(options.GamePort); coordinator.SetupPorts(num_agents, options.StartPort, false); - // NB (alkurbatov): Increase speed of steps processing. - // Disables ability to control your bot during game. + // NB (alkurbatov): Increase speed of steps processing by disabling ability + // to control your bot during game. // Recommended for competitions. coordinator.SetRawAffectsSelection(true); coordinator.JoinGame(); - coordinator.SetTimeoutMS(10000); - std::cout << "Successfully joined game" << std::endl; + coordinator.SetTimeoutMS(ResponseTimeoutMS); + std::cout << "Successfully joined game\n"; - while (coordinator.Update()) - {} + while (coordinator.Update()) {} return 0; +} catch (const std::exception& e) { + std::cerr << "Fatal error: " << e.what() << '\n'; + return 1; +} catch (...) { + std::cerr << "Fatal error: unknown exception\n"; + return 1; } #else -int main(int argc, char* argv[]) -{ - if (argc < 2) - { - std::cerr << "Provide either name of the map file or path to it!" << std::endl; +auto main(int argc, char* argv[]) -> int +try { + if (argc < 2) { + std::cerr << "Provide either name of the map file or path to it!\n"; return 1; } @@ -105,24 +150,23 @@ int main(int argc, char* argv[]) // coordinator.SetRealtime(true); Bot bot; - coordinator.SetParticipants( - { - CreateParticipant(sc2::Race::Random, &bot, "BlankBot"), - CreateComputer( - sc2::Race::Random, - sc2::Difficulty::CheatInsane, - sc2::AIBuild::Rush, - "CheatInsane" - ) - }); + coordinator.SetParticipants({ + CreateParticipant(sc2::Race::Random, &bot, "BlankBot"), + CreateComputer(sc2::Race::Random, sc2::Difficulty::CheatInsane, sc2::AIBuild::Rush, "CheatInsane"), + }); coordinator.LaunchStarcraft(); coordinator.StartGame(argv[1]); - while (coordinator.Update()) - {} + while (coordinator.Update()) {} return 0; +} catch (const std::exception& e) { + std::cerr << "Fatal error: " << e.what() << '\n'; + return 1; +} catch (...) { + std::cerr << "Fatal error: unknown exception\n"; + return 1; } #endif From ec2e4a871396770817d0953498c3865f5080de1b Mon Sep 17 00:00:00 2001 From: Alexander Kurbatov Date: Wed, 16 Sep 2026 15:32:40 +0300 Subject: [PATCH 7/9] build(ci): Determine CPU cores in runtime As GitHub improved default environments and I don't want to change the code when something else changes. Signed-off-by: Alexander Kurbatov --- .github/workflows/ci.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d9db10f..4bdc10e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,10 +18,17 @@ env: jobs: basic_build: + name: basic_build (${{ matrix.os }}) runs-on: ${{ matrix.os }} strategy: matrix: - os: [windows-latest, macos-latest, ubuntu-latest] + include: + - os: windows-latest + cores_cmd: echo $NUMBER_OF_PROCESSORS + - os: macos-latest + cores_cmd: sysctl -n hw.logicalcpu + - os: ubuntu-latest + cores_cmd: nproc steps: - uses: actions/checkout@v7.0.1 @@ -32,7 +39,8 @@ jobs: run: cmake -B ${{env.BUILD_DIR}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - name: Build - run: cmake --build ${{env.BUILD_DIR}} --config ${{env.BUILD_TYPE}} --parallel + shell: bash + run: cmake --build ${{env.BUILD_DIR}} --config ${{env.BUILD_TYPE}} --parallel $(${{ matrix.cores_cmd }}) ladder_build: runs-on: ubuntu-22.04 @@ -46,4 +54,4 @@ jobs: run: cmake -B ${{env.BUILD_DIR}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_FOR_LADDER=ON -DSC2_VERSION=4.10.0 - name: Build - run: cmake --build ${{env.BUILD_DIR}} --config ${{env.BUILD_TYPE}} --parallel + run: cmake --build ${{env.BUILD_DIR}} --config ${{env.BUILD_TYPE}} --parallel $(nproc) From 778997c77c99b912a8f0347aa090ca6f15024425 Mon Sep 17 00:00:00 2001 From: Alexander Kurbatov Date: Wed, 16 Sep 2026 15:36:02 +0300 Subject: [PATCH 8/9] docs: Update build instructions Signed-off-by: Alexander Kurbatov --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index cb663ef..9063cca 100644 --- a/README.md +++ b/README.md @@ -33,13 +33,13 @@ channel of the [AI Arena](https://discord.gg/YurYAgHRSw) Discord server. ## Build instructions -> :construction: This project requires a compiler with C++17 support. +> :construction: This project requires a compiler with C++20 support. 1. Before proceeding further download the [actual map pack](https://aiarena.net/wiki/maps/). 1. Put the downloaded maps into the `Maps` folder (create it if the folder doesn't exist): * Windows: `C:\Program Files\StarCraft II\Maps` - * OS X: `/Applications/StarCraft II/Maps` + * macOS: `/Applications/StarCraft II/Maps` * Linux: anywhere. ### Windows @@ -48,7 +48,7 @@ For building for Windows under WSL2, see [WSL2 Support](#wsl2-support). 1. Install [CMake](https://cmake.org/download/). -1. Download and install Visual Studio ([2017](https://www.visualstudio.com/downloads/) or newer). +1. Download and install Visual Studio ([2022](https://www.visualstudio.com/downloads/) or newer). 1. Get the project. @@ -104,20 +104,20 @@ For building for Windows under WSL2, see [WSL2 Support](#wsl2-support). 1. Build the project. ```bash - cmake --build build --parallel $(nproc) + cmake --build build --parallel $(sysctl -n hw.logicalcpu) ``` 1. Launch the bot with the specified absolute path to a SC2 map, e.g.: ```bash - ./build/bin/BlankBot "/home/alkurbatov/Ladder2019Season3/AcropolisLE.SC2Map" + ./build/bin/BlankBot "/Users/alkurbatov/Ladder2019Season3/AcropolisLE.SC2Map" ``` ### Linux 1. Install [CMake](https://cmake.org/download/). -1. Install `gcc-c++`. +1. Install a C++ compiler (`g++` on Debian/Ubuntu, `gcc-c++` on Fedora/RHEL). 1. Install the `make` utility. @@ -155,7 +155,7 @@ Cross compiling for Windows under WSL2 is supported through `cpp-sc2`. See the ` By default, the API assumes the latest version of the game client. The assumed version can be found in cmake's output, e.g.: ```bash $ cmake -B build | grep "SC2 version" -Target SC2 version: 5.0.5 +Target SC2 version: 5.0.14 ... ``` @@ -199,10 +199,10 @@ remove the `build` folder or the `CMakeCache.txt` file, or explicitly re-specify ### Build freezes (Linux or macOS) -If project compilation freezes, decrease nproc to 1 or more, e.g.: +If project compilation freezes, decrease the number of parallel jobs, e.g.: ``` bash -cmake --build build --parallel $(nproc --ignore=1) +cmake --build build --parallel 2 ``` ## License From c75a68cda652bf3d92fc8e7816aa37ccfa564a82 Mon Sep 17 00:00:00 2001 From: Alexander Kurbatov Date: Wed, 16 Sep 2026 15:42:49 +0300 Subject: [PATCH 9/9] fix: Broken build on Windows in CI Signed-off-by: Alexander Kurbatov --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4bdc10e..5161220 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,11 +36,11 @@ jobs: submodules: recursive - name: Configure - run: cmake -B ${{env.BUILD_DIR}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + run: cmake -B "${{env.BUILD_DIR}}" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - name: Build shell: bash - run: cmake --build ${{env.BUILD_DIR}} --config ${{env.BUILD_TYPE}} --parallel $(${{ matrix.cores_cmd }}) + run: cmake --build "${{env.BUILD_DIR}}" --config ${{env.BUILD_TYPE}} --parallel $(${{ matrix.cores_cmd }}) ladder_build: runs-on: ubuntu-22.04 @@ -51,7 +51,7 @@ jobs: submodules: recursive - name: Configure - run: cmake -B ${{env.BUILD_DIR}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_FOR_LADDER=ON -DSC2_VERSION=4.10.0 + run: cmake -B "${{env.BUILD_DIR}}" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_FOR_LADDER=ON -DSC2_VERSION=4.10.0 - name: Build - run: cmake --build ${{env.BUILD_DIR}} --config ${{env.BUILD_TYPE}} --parallel $(nproc) + run: cmake --build "${{env.BUILD_DIR}}" --config ${{env.BUILD_TYPE}} --parallel $(nproc)