diff --git a/python-api-src/library.cpp b/python-api-src/library.cpp index 227129e374ebdf5f28f36328dcfb7aa50546878b..8cfda7a02fe1c56399a0826a22c7b1dc14295b51 100644 --- a/python-api-src/library.cpp +++ b/python-api-src/library.cpp @@ -73,8 +73,26 @@ 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("carry_vespene", &IDABot::isCarryingVespene, "If unit carries a vespene") - .def("carry_mineral", &IDABot::isCarryingMineral, "If unit carries a mineral") + .def("is_unit_carry_vespene", &IDABot::IsUnitCarryVespene, "If unit carries a vespene") + .def("is_unit_carry_mineral", &IDABot::IsUnitCarryMineral, "If unit carries a mineral") + .def("debug_create_unit", &IDABot::DebugCreateUnit, "Create unit from debug mode") + .def("debug_kill_unit", &IDABot::DebugKillUnit, "Kill unit from debug mode") + .def("debug_show_map", &IDABot::DebugShowMap, "Show the entire map through debug mode") + .def("debug_fast_build", &IDABot::DebugFastBuild, "Set build time to 1 through debug mode") + .def("debug_enemy_control", &IDABot::DebugEnemyControl, "Control the enemy through debug mode") + .def("debug_ignore_food", &IDABot::DebugIgnoreFood, "Ignore the food through debug mode") + .def("debug_ignore_resource_cost", &IDABot::DebugIgnoreResourceCost, "Ignore the resource cost through debug mode") + .def("debug_give_all_resources", &IDABot::DebugGiveAllResources, "Give all the resources through debug mode") + .def("debug_god_mode", &IDABot::DebugGodMode, "Give the player god mode") + .def("debug_ignore_mineral", &IDABot::DebugIgnoreMineral, "Ignore the mineral cost through debug mode") + .def("debug_no_cooldowns", &IDABot::DebugNoCooldowns, "Deactive cooldowns through debug mode") + .def("debug_give_all_tech", &IDABot::DebugGiveAllTech, "Give all the tech to the player through debug mode") + .def("debug_give_all_upgrades", &IDABot::DebugGiveAllUpgrades, "Give all the upgrades to the player trough debug mode") + .def("debug_set_score", &IDABot::DebugSetScore, "Set the Players score through debug mode") + .def("debug_end_game", &IDABot::DebugEndGame, "End the game through debug mode") + .def("debug_set_energy", &IDABot::DebugSetEnergy, "Set the energy on a unit through debug mode") + .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_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 f29a67e3c5d0d089970f14494dad5c343b0507ee..871f0dcfe83aa3a09d7446160817989d6f67708c 100644 --- a/src/IDABot.cpp +++ b/src/IDABot.cpp @@ -1,6 +1,7 @@ #include "IDABot.h" #include "Util.h" + IDABot::IDABot() : m_map(*this) , m_bases(*this) @@ -229,14 +230,105 @@ const TypeData & IDABot::Data(const MetaType & type) const API extended summer 2020 */ -bool IDABot::isCarryingVespene(Unit const unit) const +bool IDABot::IsUnitCarryVespene(Unit const unit) const { const sc2::Unit * sc2unit = unit.getUnitPtr(); return Observation()->IsUnitCarryVespene(*sc2unit); } -bool IDABot::isCarryingMineral(Unit const unit) const +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); +} + +void IDABot::DebugKillUnit(const Unit unit) +{ + Debug()->DebugKillUnit(unit.getUnitPtr()); +} + +void IDABot::DebugShowMap() +{ + Debug()->DebugShowMap(); +} + +void IDABot::DebugFastBuild() +{ + Debug()->DebugFastBuild(); +} + +void IDABot::DebugEnemyControl() +{ + Debug()->DebugEnemyControl(); +} + +void IDABot::DebugIgnoreFood() +{ + Debug()->DebugIgnoreFood(); +} + +void IDABot::DebugIgnoreResourceCost() +{ + Debug()->DebugIgnoreResourceCost(); +} + +void IDABot::DebugGiveAllResources() +{ + Debug()->DebugGiveAllResources(); +} + +void IDABot::DebugGodMode() +{ + Debug()->DebugGodMode(); +} + +void IDABot::DebugIgnoreMineral() +{ + Debug()->DebugIgnoreMineral(); +} + +void IDABot::DebugNoCooldowns() +{ + Debug()->DebugIgnoreMineral(); +} + +void IDABot::DebugGiveAllTech() +{ + Debug()->DebugGiveAllTech(); +} + +void IDABot::DebugGiveAllUpgrades() +{ + Debug()->DebugGiveAllUpgrades(); +} + +void IDABot::DebugSetScore(float score) +{ + Debug()->DebugSetScore(score); +} + +void IDABot::DebugEndGame(bool victory) +{ + Debug()->DebugEndGame(victory); +} + +void IDABot::DebugSetEnergy(float value, const Unit unit) +{ + Debug()->DebugSetEnergy(value, unit.getUnitPtr()); +} + +void IDABot::DebugSetLife(float value, const Unit unit) +{ + Debug()->DebugSetLife(value, unit.getUnitPtr()); +} + +void IDABot::DebugSetShields(float value, const Unit unit) +{ + Debug()->DebugSetShields(value, unit.getUnitPtr()); +} + diff --git a/src/IDABot.h b/src/IDABot.h index 8f10a681209e68e169c10409cf5a7635c75f37e4..5c4d3a891f349486d77ece41cce9f2f6bf90d0b0 100644 --- a/src/IDABot.h +++ b/src/IDABot.h @@ -14,6 +14,8 @@ #include "MetaType.h" #include "Unit.h" +using sc2::UnitTypeID; + class IDABot : public sc2::Agent { MapTools m_map; @@ -61,10 +63,29 @@ public: /* API extended summer 2020 - */ - bool isCarryingVespene(Unit const unit) const; - bool isCarryingMineral(Unit const unit) const; + 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(); + void DebugFastBuild(); + void DebugEnemyControl(); + void DebugIgnoreFood(); + void DebugIgnoreResourceCost(); + void DebugGiveAllResources(); + void DebugGodMode(); + void DebugIgnoreMineral(); + void DebugNoCooldowns(); + void DebugGiveAllTech(); + void DebugGiveAllUpgrades(); + void DebugSetScore(float score); + void DebugEndGame(bool victory); + void DebugSetEnergy(float value, const Unit unit); + void DebugSetLife(float value, const Unit unit); + void DebugSetShields(float value, const Unit unit); + Unit findClosestWorkerTo(std::vector<Unit> & unitsToAssign, const CCPosition & target); + // Not needed, just convenience functions const TypeData & Data(const UnitType & type) const;