diff --git a/python-api-src/lib_unit.cpp b/python-api-src/lib_unit.cpp index efc4802da6612f53fa8b47c08b810a0181300a6b..dbb4c017add1eb2ba141ff34bed01e3b9a15af2e 100644 --- a/python-api-src/lib_unit.cpp +++ b/python-api-src/lib_unit.cpp @@ -35,7 +35,9 @@ void define_unit(py::module & m) .def_property_readonly("facing", &Unit::getFacing) .def_property_readonly("radius", &Unit::getRadius) .def_property_readonly("is_carrying_minerals", &Unit::isCarryingMinerals) - .def_property_readonly("gas_left_in_refinery", &Unit::gasLeftInRefinery) + .def_property_readonly("gas_left_in_refinery", &Unit::gasLeftInGeyser) + .def_property_readonly("minerals_left_in_mineralfield", &Unit::mineralsLeftInMineralfield) + .def_property_readonly("owner", &Unit::getOwner) .def("hold_position", &Unit::holdPosition) .def("patrol", py::overload_cast<const CCPosition &>(&Unit::patrol, py::const_)) .def("stop_dance", &Unit::stopDance) diff --git a/python-api-src/library.cpp b/python-api-src/library.cpp index 2aa1198cb45d4cb0d3636a3a01ef060a3a22da94..832d9f5349d97355f955ffb77277b30d537254cf 100644 --- a/python-api-src/library.cpp +++ b/python-api-src/library.cpp @@ -94,6 +94,8 @@ PYBIND11_MODULE(library, m) .def("debug_set_life", &IDABot::DebugSetLife, "Set the life on a unit through debug mode") .def("debug_set_shield", &IDABot::DebugSetShields, "Set the shields on a unit through debug mode") .def("get_enemy_base_location", &IDABot::GetEnemyBaseLocations, "Return the CCpostion of the enemy base") + .def("move_camera", &IDABot::CameraMove, "Move the camera to p postion", "p"_a) + .def("has_creep", &IDABot::HasCreep, "Returns true if there is creep at position p", "p"_a) .def_property_readonly("base_location_manager", &IDABot::Bases) .def_property_readonly("tech_tree", &IDABot::GetTechTree) .def_property_readonly("map_tools", &IDABot::Map) diff --git a/src/IDABot.cpp b/src/IDABot.cpp index 4331f5e848cd3c8c417c5c2f29e84b3cabef2316..2e4ae39080bd438b0ecd91b164d788c655901f14 100644 --- a/src/IDABot.cpp +++ b/src/IDABot.cpp @@ -339,3 +339,10 @@ const std::vector<Point2D> IDABot::GetEnemyBaseLocations() return Observation()->GetGameInfo().enemy_start_locations; } +bool IDABot::HasCreep(Point2D p) const { + return Observation()->HasCreep(p); +} + +void IDABot::CameraMove(Point2DI p) { + ActionsFeatureLayer()->CameraMove(p); +} \ No newline at end of file diff --git a/src/IDABot.h b/src/IDABot.h index 01bb6062f97d13c1b484ad52ec14d61047b3cdd3..7fba6b34f97a32a2f6c8e12efa361056b7e2dd64 100644 --- a/src/IDABot.h +++ b/src/IDABot.h @@ -16,6 +16,7 @@ using sc2::UnitTypeID; using sc2::Point2D; +using sc2::Point2DI; class IDABot : public sc2::Agent { @@ -86,6 +87,8 @@ public: void DebugSetLife(float value, const Unit unit); void DebugSetShields(float value, const Unit unit); const std::vector<Point2D> GetEnemyBaseLocations(); + bool HasCreep(Point2D p) const; + void CameraMove(Point2DI p); // Not needed, just convenience functions diff --git a/src/Unit.cpp b/src/Unit.cpp index 8d833317e275be282b5ec0c9d2def443a6b7810c..04d80c681d53235f0c8d9801c319edd49ed816c2 100644 --- a/src/Unit.cpp +++ b/src/Unit.cpp @@ -440,8 +440,20 @@ bool Unit::isCarryingMinerals() const return false; } -int Unit::gasLeftInRefinery() const +int Unit::gasLeftInGeyser() const { BOT_ASSERT(isValid(), "Unit is not valid"); return m_unit->vespene_contents; } + +int Unit::mineralsLeftInMineralfield() const +{ + BOT_ASSERT(isValid(), "Unit is not valid"); + return m_unit->mineral_contents; +} + +int Unit::getOwner() const +{ + BOT_ASSERT(isValid(), "Unit is not valid"); + return m_unit->owner; +} diff --git a/src/Unit.h b/src/Unit.h index 874c36f2fe143e4b9ae7298dafea0125e0a9e2d0..2275b2ca5b9293d681010fc2df8779e37ad5e1b5 100644 --- a/src/Unit.h +++ b/src/Unit.h @@ -64,7 +64,9 @@ public: /* API extended summer 2020 */ - int gasLeftInRefinery() const; + int gasLeftInGeyser() const; + int mineralsLeftInMineralfield() const; + int getOwner() const; void stop () const;