diff --git a/python-api-src/lib_unit.cpp b/python-api-src/lib_unit.cpp index dbb4c017add1eb2ba141ff34bed01e3b9a15af2e..f7ba369c1cdb4c7cf136feaed86aace5522895d7 100644 --- a/python-api-src/lib_unit.cpp +++ b/python-api-src/lib_unit.cpp @@ -35,6 +35,7 @@ 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("is_carrying_gas", &Unit::isCarryingGas) .def_property_readonly("gas_left_in_refinery", &Unit::gasLeftInGeyser) .def_property_readonly("minerals_left_in_mineralfield", &Unit::mineralsLeftInMineralfield) .def_property_readonly("owner", &Unit::getOwner) diff --git a/python-api-src/library.cpp b/python-api-src/library.cpp index 832d9f5349d97355f955ffb77277b30d537254cf..1c59abb89366b7100c46e995e974cbf7ba7dad54 100644 --- a/python-api-src/library.cpp +++ b/python-api-src/library.cpp @@ -73,8 +73,6 @@ PYBIND11_MODULE(library, m) .def("get_all_units", &IDABot::GetAllUnits, "Returns a list of all units") .def("get_my_units", &IDABot::GetMyUnits, "Returns a list of all units beloning to the player") .def("get_player_race", &IDABot::GetPlayerRace) - .def("is_unit_carry_vespene", &IDABot::IsUnitCarryVespene, "If unit carries a vespene", "unit"_a) - .def("is_unit_carry_mineral", &IDABot::IsUnitCarryMineral, "If unit carries a mineral", "unit"_a) .def("debug_create_unit", &IDABot::DebugCreateUnit, "unit_type"_a, "p"_a, "player_id"_a = 1, "count"_a = 1) .def("debug_kill_unit", &IDABot::DebugKillUnit, "Kill unit from debug mode") .def("debug_show_map", &IDABot::DebugShowMap, "Show the entire map through debug mode") diff --git a/src/BuildingPlacer.cpp b/src/BuildingPlacer.cpp index 008fb521efee9f8bd2ea5509f72cfb6e1ad3509f..988ceca16c0197e8f765ab37c242e739c0be4160 100644 --- a/src/BuildingPlacer.cpp +++ b/src/BuildingPlacer.cpp @@ -95,6 +95,8 @@ bool BuildingPlacer::canBuildHereWithSpace(int bx, int by, const UnitType & type return true; } +// BuildDist is the distance from the position where the building is gonna be placed. + CCTilePosition BuildingPlacer::getBuildLocationNear(const CCTilePosition & p, const UnitType & t, int buildDist, size_t search_count) const { //Timer t; diff --git a/src/IDABot.cpp b/src/IDABot.cpp index 2e4ae39080bd438b0ecd91b164d788c655901f14..dc70bd380867149a14aaaa83399a3f52ed4f11a1 100644 --- a/src/IDABot.cpp +++ b/src/IDABot.cpp @@ -230,18 +230,6 @@ const TypeData & IDABot::Data(const MetaType & type) const API extended summer 2020 */ -bool IDABot::IsUnitCarryVespene(Unit const unit) const -{ - const sc2::Unit * sc2unit = unit.getUnitPtr(); - return Observation()->IsUnitCarryVespene(*sc2unit); -} - -bool IDABot::IsUnitCarryMineral(Unit const unit) const -{ - const sc2::Unit * sc2unit = unit.getUnitPtr(); - return Observation()->IsUnitCarryMineral(*sc2unit); -} - void IDABot::DebugCreateUnit(UnitTypeID unit_type, const CCPosition& p, uint32_t player_id, uint32_t count) { Debug()->DebugCreateUnit(unit_type, p, player_id, count); diff --git a/src/IDABot.h b/src/IDABot.h index 7fba6b34f97a32a2f6c8e12efa361056b7e2dd64..b55508444e3f3f42079ece999fa1bf6de2bdf698 100644 --- a/src/IDABot.h +++ b/src/IDABot.h @@ -66,8 +66,6 @@ public: /* API extended summer 2020 */ - bool IsUnitCarryVespene(Unit const unit) const; - bool IsUnitCarryMineral(Unit const unit) const; void DebugCreateUnit(UnitTypeID unit_type, const CCPosition& p, uint32_t player_id = 1, uint32_t count = 1); void DebugKillUnit(const Unit unit); void DebugShowMap(); diff --git a/src/Unit.cpp b/src/Unit.cpp index 04d80c681d53235f0c8d9801c319edd49ed816c2..ff4c26f2eff10ade772578a9e6ec70ac470c1326 100644 --- a/src/Unit.cpp +++ b/src/Unit.cpp @@ -426,6 +426,8 @@ void Unit::stopDance() const m_bot->Actions()->UnitCommand(m_unit, sc2::ABILITY_ID::STOP_DANCE); } +/* +// Implementation by Dawid Abucewicz bool Unit::isCarryingMinerals() const { BOT_ASSERT(isValid(), "Unit is not valid"); @@ -439,6 +441,7 @@ bool Unit::isCarryingMinerals() const } return false; } +*/ int Unit::gasLeftInGeyser() const { @@ -457,3 +460,14 @@ int Unit::getOwner() const BOT_ASSERT(isValid(), "Unit is not valid"); return m_unit->owner; } + +// Implemented with Blizzard SC2 API +bool Unit::isCarryingGas() const +{ + return m_bot->Observation()->IsUnitCarryVespene(*m_unit); +} + +bool Unit::isCarryingMinerals() const +{ + return m_bot->Observation()->IsUnitCarryMineral(*m_unit); +} \ No newline at end of file diff --git a/src/Unit.h b/src/Unit.h index 2275b2ca5b9293d681010fc2df8779e37ad5e1b5..a996e372f147d49522e1f833aacfd5c5143326b0 100644 --- a/src/Unit.h +++ b/src/Unit.h @@ -67,6 +67,7 @@ public: int gasLeftInGeyser() const; int mineralsLeftInMineralfield() const; int getOwner() const; + bool isCarryingGas() const; void stop () const;