diff --git a/python-api-src/library.cpp b/python-api-src/library.cpp index 80cc71de91c0c9a1e2e97c43a6aaad4a2fb9c060..36356f6556399c21592ede897fe34107f95fcf17 100644 --- a/python-api-src/library.cpp +++ b/python-api-src/library.cpp @@ -29,14 +29,10 @@ PYBIND11_MODULE(library, m) .value("Protoss", sc2::Race::Protoss) .value("Random", sc2::Race::Random); - // Stupid anonymous enum, used as int everywhere. Best work-around I could think of. - py::module players = m.def_submodule("Players", "Constants for referring to players"); - players.attr("Self") = (int) Players::Self; - players.attr("Enemy") = (int) Players::Enemy; - players.attr("Neutral") = (int) Players::Neutral; - players.attr("Ally") = (int) Players::Ally; - players.attr("Size") = (int) Players::Size; // These are probably used for - players.attr("None") = (int) Players::None; // creating arrays of fixed length?? + m.attr("PLAYER_SELF") = py::int_((int) Players::Self); + m.attr("PLAYER_ENEMY") = py::int_((int) Players::Enemy); + m.attr("PLAYER_NEUTRAL") = py::int_((int) Players::Neutral); + m.attr("PLAYER_ALLY") = py::int_((int) Players::Ally); /* TODO: These also needs to be defined @@ -87,24 +83,22 @@ PYBIND11_MODULE(library, m) .value("CheatMoney", sc2::Difficulty::CheatMoney) .value("CheatInsane", sc2::Difficulty::CheatInsane); - py::class_<sc2::Color>(m, "Color") - .def(py::init<>()) - .def(py::init<int, int, int>()) - .def_readwrite("r", &sc2::Color::r) - .def_readwrite("g", &sc2::Color::g) - .def_readwrite("b", &sc2::Color::b); - - py::module colors = m.def_submodule("Colors", "Constants for common colors"); - colors.attr("White") = sc2::Colors::White; - colors.attr("Red") = sc2::Colors::Red; - colors.attr("Green") = sc2::Colors::Green; - colors.attr("Yellow") = sc2::Colors::Yellow; - colors.attr("Blue") = sc2::Colors::Blue; - colors.attr("Teal") = sc2::Colors::Teal; - colors.attr("Purple") = sc2::Colors::Purple; - colors.attr("Black") = sc2::Colors::Black; - colors.attr("Gray") = sc2::Colors::Gray; - - m.def("create_participants", &sc2::CreateParticipant, "Create participant from agent"); - m.def("create_computer", &sc2::CreateComputer, "Create participant from built-in Starcraft computer"); + py::class_<sc2::Color> color(m, "Color"); + color.def(py::init<>()); + color.def(py::init<int, int, int>(), "r"_a, "g"_a, "b"_a); + color.def_readwrite("r", &sc2::Color::r); + color.def_readwrite("g", &sc2::Color::g); + color.def_readwrite("b", &sc2::Color::b); + color.attr("WHITE") = sc2::Colors::White; + color.attr("RED") = sc2::Colors::Red; + color.attr("GREEN") = sc2::Colors::Green; + color.attr("YELLOW") = sc2::Colors::Yellow; + color.attr("BLUE") = sc2::Colors::Blue; + color.attr("TEAL") = sc2::Colors::Teal; + color.attr("PURPLE") = sc2::Colors::Purple; + color.attr("BLACK") = sc2::Colors::Black; + color.attr("GRAY") = sc2::Colors::Gray; + + m.def("create_participants", &sc2::CreateParticipant, "Create participant from bot", "race"_a, "bot"_a); + m.def("create_computer", &sc2::CreateComputer, "Create participant from built-in Starcraft computer", "race"_a, "difficulty"_a); }