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

Added vespene gas amount for geyser and updated Buildingplacer

parent 1676cf56
Branches
Tags
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("gas_left_in_refinery", &Unit::gasLeftInRefinery)
.def("hold_position", &Unit::holdPosition)
.def("patrol", py::overload_cast<const CCPosition &>(&Unit::patrol, py::const_))
.def("stop_dance", &Unit::stopDance)
......
......@@ -73,9 +73,9 @@ 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")
.def("is_unit_carry_mineral", &IDABot::IsUnitCarryMineral, "If unit carries a mineral")
.def("debug_create_unit", &IDABot::DebugCreateUnit, "Create unit from debug mode")
.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")
.def("debug_fast_build", &IDABot::DebugFastBuild, "Set build time to 1 through debug mode")
......@@ -93,7 +93,7 @@ PYBIND11_MODULE(library, m)
.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("get_enemy_base_location", &IDABot::GetEnemyBaseLocation, "Return the CCpostion of the enemy base")
.def("get_enemy_base_location", &IDABot::GetEnemyBaseLocations, "Return the CCpostion of the enemy base")
.def_property_readonly("base_location_manager", &IDABot::Bases)
.def_property_readonly("tech_tree", &IDABot::GetTechTree)
.def_property_readonly("map_tools", &IDABot::Map)
......
......@@ -66,13 +66,13 @@ bool BuildingPlacer::canBuildHereWithSpace(int bx, int by, const UnitType & type
// define the rectangle of the building spot
int startx = bx - buildDist;
int starty = by - buildDist;
int endx = bx + width + buildDist;
int endy = by + height + buildDist;
int endx = bx + width + buildDist - 1;
int endy = by + height + buildDist - 1;
// TODO: recalculate start and end positions for addons
// if this rectangle doesn't fit on the map we can't build here
if (startx < 0 || starty < 0 || endx > m_bot.Map().width() || endx < bx + width || endy > m_bot.Map().height())
if (startx < 0 || starty < 0 || endx > m_bot.Map().width() || endx < bx + width - 1 || endy > m_bot.Map().height() - 1)
{
return false;
}
......@@ -191,6 +191,7 @@ void BuildingPlacer::reserveTiles(int bx, int by, int width, int height)
void BuildingPlacer::drawReservedTiles()
{
// Why is there a return here? Should we not use the function? /Hannes Jmtner
return;
int rwidth = (int)m_reserveMap.size();
int rheight = (int)m_reserveMap[0].size();
......@@ -227,6 +228,7 @@ CCTilePosition BuildingPlacer::getRefineryPosition()
double minGeyserDistanceFromHome = std::numeric_limits<double>::max();
CCPosition homePosition = m_bot.GetStartLocation();
for (auto & unit : m_bot.GetAllUnits())
{
if (!unit.getType().isGeyser())
......
......@@ -334,7 +334,7 @@ void IDABot::DebugSetShields(float value, const Unit unit)
// There is a bug in the latest SC2
// This a function to get the enemy base instead of using build location manager
const std::vector<Point2D> IDABot::GetEnemyBaseLocation()
const std::vector<Point2D> IDABot::GetEnemyBaseLocations()
{
return Observation()->GetGameInfo().enemy_start_locations;
}
......
......@@ -85,7 +85,7 @@ public:
void DebugSetEnergy(float value, const Unit unit);
void DebugSetLife(float value, const Unit unit);
void DebugSetShields(float value, const Unit unit);
const std::vector<Point2D> GetEnemyBaseLocation();
const std::vector<Point2D> GetEnemyBaseLocations();
// Not needed, just convenience functions
......
......@@ -439,3 +439,9 @@ bool Unit::isCarryingMinerals() const
}
return false;
}
int Unit::gasLeftInRefinery() const
{
BOT_ASSERT(isValid(), "Unit is not valid");
return m_unit->vespene_contents;
}
......@@ -60,6 +60,11 @@ public:
void stopDance() const;
float getFacing() const;
float getRadius() const;
/*
API extended summer 2020
*/
int gasLeftInRefinery() const;
void stop () const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment