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

Added the functions for unit and IDABot

parent c1580e95
No related branches found
No related tags found
1 merge request!7Uppdaterat API
......@@ -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)
......
......@@ -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)
......
......@@ -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
......@@ -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
......
......@@ -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;
}
......@@ -64,7 +64,9 @@ public:
/*
API extended summer 2020
*/
int gasLeftInRefinery() const;
int gasLeftInGeyser() const;
int mineralsLeftInMineralfield() const;
int getOwner() 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