Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebase to latest api #2

Merged
merged 4 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
os: [windows-latest, macos-latest, ubuntu-latest]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: recursive

Expand Down
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

24 changes: 15 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.15)

project(CommandCenter)

include(FetchContent)

# Specify output directories.
set(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin")

# Build with c++14 support, required by sc2api.
set(CMAKE_CXX_STANDARD 14)

# Disable building of examples in the sc2api submodule.
set(BUILD_API_EXAMPLES OFF CACHE INTERNAL "" FORCE)
if (MSVC)
# Setup MSVC parallelized builds
add_compile_options(/MP)

# Use statically linked runtime
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$<CONFIG:Debug>:Debug>)
endif ()

# Disable building of tests in the sc2api submodule.
set(BUILD_API_TESTS OFF CACHE INTERNAL "" FORCE)
list(APPEND CMAKE_MODULE_PATH thirdparty/cmake)

# Dont build sc2renderer in the sc2api submodule.
set(BUILD_SC2_RENDERER OFF CACHE INTERNAL "" FORCE)
# Dependencies
include(cpp_sc2)
include_directories(thirdparty)

add_subdirectory("cpp-sc2")
add_subdirectory("src")
add_subdirectory(src)
55 changes: 32 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,56 +41,65 @@ By default when you run CommandCenter.exe, it will play as Random race vs. a Ran

If the bot crashes or does other nasty things, please bear with me while I make it more stable :)

# Developer Install / Compile Instructions (Windows)
# Developer Install / Compile Instructions
## Windows
* Download and install [Visual Studio 2017 or newer](https://www.visualstudio.com/downloads/)
* Install [CMake](https://cmake.org/download/) and do

```bat
:: Get the project.
$ git clone --recursive [email protected]:cpp-sc2/commandcenter.git
$ git clone [email protected]:cpp-sc2/commandcenter.git
$ cd commandcenter

:: Create build directory.
$ mkdir build
$ cd build

:: Create Visual Studio project files.
:: For Visual Studio 2019.
$ cmake ../ -G "Visual Studio 16 2019"
:: For Visual Studio 2017.
$ cmake ../ -G "Visual Studio 15 2017 Win64"
:: For Visual Studio 2022.
$ cmake -B build -G "Visual Studio 17 2022"

:: Build the project using Visual Studio.
:: The binary "CommandCenter_API.exe" should appear in the build/bin/ directory
$ start CommandCenter.sln

:: Launch the bot with the specified path to a SC2 map.
:: Warning: The CommandCenter/bin/BotConfig.txt file must be in the same directory as the .exe to run properly
$ bin\Debug\CommandCenter.exe Ladder2019Season3/AcropolisLE.SC2Map
$ build\bin\Debug\CommandCenter.exe Ladder2019Season3/AcropolisLE.SC2Map
```

# Developer Install / Compile Instructions (Linux and OS X)
* OS X: Download and install XCode and Xcode command-line tools.
* Linux: Install 'gcc-c++' with C++14 support and the 'make' utility.
* Install [CMake](https://cmake.org/download/) and do
## OS X
* Download and install XCode and XCode command-line tools.
* Install [CMake](https://cmake.org/download/).

```bash
# Get the project.
$ git clone --recursive [email protected]:cpp-sc2/commandcenter.git && cd commandcenter
$ git clone [email protected]:cpp-sc2/commandcenter.git && cd commandcenter

# Generate CMake build tree
$ cmake -B build -G Xcode

# Build the project.
$ cmake --build build --parallel --verbose

# Launch the bot with the specified path to a SC2 map.
# Warning: The CommandCenter/bin/BotConfig.txt file must be in the same directory as the executable to run properly
$ build/bin/CommandCenter Ladder2019Season3/AcropolisLE.SC2Map
```

# Create build directory.
$ mkdir build && cd build
## Linux
* Install 'gcc-c++' with C++14 support and the 'make' utility.
* Install [CMake](https://cmake.org/download/).

```bash
# Get the project.
$ git clone [email protected]:cpp-sc2/commandcenter.git && cd commandcenter

# Generate a Makefile.
# Use 'cmake -DCMAKE_BUILD_TYPE=Debug ../' if debuginfo is needed
$ cmake ../
# Generate CMake build tree
$ cmake -B build

# Build the project.
$ VERBOSE=1 cmake --build . --parallel
$ cmake --build build --parallel --verbose

# Launch the bot with the specified path to a SC2 map.
# Warning: The CommandCenter/bin/BotConfig.txt file must be in the same directory as the executable to run properly
$ bin/Debug/CommandCenter Ladder2019Season3/AcropolisLE.SC2Map
$ build/bin/CommandCenter Ladder2019Season3/AcropolisLE.SC2Map
```

# Bot Development
Expand Down
1 change: 0 additions & 1 deletion cpp-sc2
Submodule cpp-sc2 deleted from c295c5
108 changes: 83 additions & 25 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,36 +1,94 @@
# All the source files for the bot.
file(GLOB BOT_SOURCES "*.cpp" "*.h" "*.hpp")

include_directories(SYSTEM
${PROJECT_SOURCE_DIR}/cpp-sc2/include
${PROJECT_SOURCE_DIR}/cpp-sc2/contrib/protobuf/src
${PROJECT_BINARY_DIR}/cpp-sc2/generated
set(BOT_SOURCES
BaseLocation.cpp
BaseLocation.h
BaseLocationManager.cpp
BaseLocationManager.h
BotAssert.cpp
BotAssert.h
BotConfig.cpp
BotConfig.h
BuildOrder.cpp
BuildOrder.h
BuildOrderQueue.cpp
BuildOrderQueue.h
Building.cpp
Building.h
BuildingData.cpp
BuildingData.h
BuildingManager.cpp
BuildingManager.h
BuildingPlacer.cpp
BuildingPlacer.h
CCBot.cpp
CCBot.h
CombatCommander.cpp
CombatCommander.h
Common.h
Condition.cpp
Condition.h
DistanceMap.cpp
DistanceMap.h
GameCommander.cpp
GameCommander.h
JSONTools.cpp
JSONTools.h
MapTools.cpp
MapTools.h
MeleeManager.cpp
MeleeManager.h
MetaType.cpp
MetaType.h
MicroManager.cpp
MicroManager.h
ProductionManager.cpp
ProductionManager.h
RangedManager.cpp
RangedManager.h
ScoutManager.cpp
ScoutManager.h
Squad.cpp
Squad.h
SquadData.cpp
SquadData.h
SquadOrder.cpp
SquadOrder.h
StrategyManager.cpp
StrategyManager.h
TechTree.cpp
TechTree.h
Timer.hpp
Unit.cpp
Unit.h
UnitData.cpp
UnitData.h
UnitInfoManager.cpp
UnitInfoManager.h
UnitType.cpp
UnitType.h
Util.cpp
Util.h
WorkerData.cpp
WorkerData.h
WorkerManager.cpp
WorkerManager.h
main.cpp
)

link_directories(${PROJECT_BINARY_DIR}/cpp-sc2/bin)
add_executable(CommandCenter ${BOT_SOURCES})

# Show more warnings at compiletime.
if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX-")
target_compile_options(CommandCenter PRIVATE /W4 /EHsc)
else ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
target_compile_options(CommandCenter PRIVATE -Wall -Wextra)
endif ()

set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")

# Create the executable.
add_executable(CommandCenter ${BOT_SOURCES})
target_link_libraries(CommandCenter sc2api sc2lib sc2utils sc2protocol civetweb libprotobuf)
target_link_libraries(CommandCenter PRIVATE cpp_sc2)

if (MINGW)
target_link_libraries(CommandCenter ssp)
endif()

if (APPLE)
target_link_libraries(CommandCenter "-framework Carbon")
endif ()

# Linux specific.
if (UNIX AND NOT APPLE)
target_link_libraries(CommandCenter pthread dl)
target_link_libraries(CommandCenter PRIVATE ssp)
elseif (APPLE)
target_link_libraries(CommandCenter PRIVATE "-framework Carbon")
elseif (UNIX AND NOT APPLE) # Building on Linux
target_link_libraries(CommandCenter PRIVATE pthread dl)
endif ()
22 changes: 22 additions & 0 deletions thirdparty/cmake/cpp_sc2.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
message(STATUS "FetchContent: cpp-sc2")

# Dont build examples in the sc2api submodule.
set(BUILD_API_EXAMPLES OFF CACHE INTERNAL "" FORCE)

# Dont build tests in the sc2api submodule.
set(BUILD_API_TESTS OFF CACHE INTERNAL "" FORCE)

# Dont build sc2renderer in the sc2api submodule.
set(BUILD_SC2_RENDERER OFF CACHE INTERNAL "" FORCE)

FetchContent_Declare(
cpp_sc2
GIT_REPOSITORY https://github.com/cpp-sc2/cpp-sc2.git
GIT_TAG e547ca137311447e4fb2af5b5c8a7642fba20b52
)
FetchContent_MakeAvailable(cpp_sc2)

set_target_properties(sc2api PROPERTIES FOLDER cpp-sc2)
set_target_properties(sc2lib PROPERTIES FOLDER cpp-sc2)
set_target_properties(sc2protocol PROPERTIES FOLDER cpp-sc2)
set_target_properties(sc2utils PROPERTIES FOLDER cpp-sc2)
File renamed without changes.