Skip to content
Snippets Groups Projects
Commit f8ec4bd0 authored by Hannes Jämtner's avatar Hannes Jämtner
Browse files

Refactor and moved function from IDABot to unit

parent 3f99ff86
No related branches found
No related tags found
1 merge request!7Uppdaterat API
......@@ -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)
......
......@@ -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")
......
......@@ -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;
......
......@@ -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);
......
......@@ -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();
......
......@@ -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
......@@ -67,6 +67,7 @@ public:
int gasLeftInGeyser() const;
int mineralsLeftInMineralfield() const;
int getOwner() const;
bool isCarryingGas() const;
void stop () const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment