diff --git a/CMakeLists.txt b/CMakeLists.txt index 191b40b3ddf615d70bf83cddfce43352d4126296..d6fa9ab8416cecabeca3412cd0ade69717b47f20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,4 +26,25 @@ set_target_properties(sc2protocol PROPERTIES COMPILE_FLAGS "/W0") set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT CommandCenter) -pybind11_add_module(library library.cxx) +# TODO: Move everything below this line to a separate directory + +include_directories(SYSTEM + ${PROJECT_SOURCE_DIR}/lib/s2client-api/include + ${PROJECT_SOURCE_DIR}/lib/s2client-api/contrib/protobuf/src + ${PROJECT_BINARY_DIR}/lib/s2client-api/generated +) + +# All the source files for the bot. +file(GLOB BOT_SOURCES "src/*.cpp" "src/*.h" "src/*.hpp") + +link_directories(${PROJECT_BINARY_DIR}/s2client-api/bin) + +# Enable compilation of the SC2 version of the bot code +# TODO: Remove all remaining BW code +add_definitions(-DSC2API) + +# Create the executable. +pybind11_add_module(library library.cpp ${BOT_SOURCES}) +target_link_libraries(library PRIVATE + sc2api sc2lib sc2utils sc2protocol libprotobuf +) diff --git a/library.cpp b/library.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bd86eb69cdbc32725b6888865eb22d825629cfca --- /dev/null +++ b/library.cpp @@ -0,0 +1,36 @@ +#include <pybind11/pybind11.h> +#include <sc2api/sc2_api.h> +#include "src/IDABot.h" +#include <iostream> + +void run() +{ + char *argv[] = { "executable", NULL}; + int argc = sizeof(argv) / sizeof(char*) - 1; + sc2::Coordinator coordinator; + coordinator.LoadSettings(argc, argv); + + IDABot bot; + coordinator.SetParticipants({ + CreateParticipant(sc2::Race::Terran, &bot), + sc2::CreateComputer(sc2::Race::Zerg) + }); + + coordinator.LaunchStarcraft(); + coordinator.StartGame("InterloperTest.SC2Map"); + + while (coordinator.Update()) { + } +} + +int add(int i, int j) +{ + return i + j + 1; +} + +PYBIND11_MODULE(library, m) +{ + m.doc() = "pybind11 example plugin"; + m.def("add", &add, "A function which adds two numbers"); + m.def("run", &run, "Start Starcraft 2"); +} diff --git a/library.cxx b/library.cxx deleted file mode 100644 index ac183e5c07990a6089cf9db8cafb811cff5652e8..0000000000000000000000000000000000000000 --- a/library.cxx +++ /dev/null @@ -1,12 +0,0 @@ -#include <pybind11/pybind11.h> - -int add(int i, int j) -{ - return i + j + 1; -} - -PYBIND11_MODULE(library, m) -{ - m.doc() = "pybind11 example plugin"; - m.def("add", &add, "A function which adds two numbers"); -} diff --git a/tutorial.cxx b/tutorial.cxx deleted file mode 100644 index b7e2b8672f147042bb5215c139e888b4a2508e39..0000000000000000000000000000000000000000 --- a/tutorial.cxx +++ /dev/null @@ -1,15 +0,0 @@ -#include <iostream> -#include <pybind11/pybind11.h> - -int add(int i, int j) -{ - return i + j; -} - -int main (int argc, char *argv[]) -{ - while (true) - { - std::cout << "Hello World!" << std::endl; - } -}