Skip to content
Snippets Groups Projects
Commit 0ff7a375 authored by Rojikku98's avatar Rojikku98
Browse files

Fixed some issues

parent 1a226715
No related branches found
No related tags found
No related merge requests found
......@@ -17,7 +17,7 @@ void define_map_tools(py::module & m)
.def_property_readonly("width", &MapTools::width, "The width of the map")
.def_property_readonly("height", &MapTools::height, "The height of the map")
.def_property_readonly("map_name", &MapTools::name, "The name of the map")
//.def("terrainHeight", &MapTools::terrainHeight, py::const_)
.def("terrainHeight", &MapTools::terrainHeightCord, "x"_a, "y"_a)
.def("draw_line", py::overload_cast<const CCPosition &, const CCPosition &, const CCColor &>(&MapTools::drawLine, py::const_), py::arg("start"), py::arg("stop"), py::arg("color") = sc2::Colors::White, "Draws a line with the given color between to two points.")
.def("draw_tile", py::overload_cast<const CCTilePosition &, const CCColor &>(&MapTools::drawTile, py::const_), py::arg("tile"), py::arg("color") = sc2::Colors::White, "Draws an outline with the given color to the given tile.")
.def("draw_box", py::overload_cast<const CCPosition &, const CCPosition &, const CCColor &>(&MapTools::drawBox, py::const_), py::arg("top_left"), py::arg("bottom_right"), py::arg("color") = sc2::Colors::White, "Draws a box with the given color from the top left cornor to the botom right")
......
......@@ -136,7 +136,8 @@ void BaseLocationManager::onStart()
void BaseLocationManager::onFrame()
{
drawBaseLocations();
//drawBaseLocations();
// make sure that mineralfields and geysers are up to date in the different bases
for (BaseLocation & baselocation : m_baseLocationData) {
......
......@@ -158,7 +158,11 @@ int IDABot::GetGas() const
}
Unit IDABot::GetUnit(const CCUnitID & tag) const
{
{
auto a = Observation()->GetUnit(tag);
if (a == nullptr) {
return Unit();
}
return Unit(Observation()->GetUnit(tag), *(IDABot *)this);
}
......@@ -392,10 +396,10 @@ float IDABot::GetScore() const
}
const sc2::GameResult IDABot::GetPlayerResults() const {
for each (auto var in (Observation()->GetResults()))
auto res = Observation()->GetResults();
for(int i = 0; i < res.size(); i++)
{
if (var.player_id == Observation()->GetPlayerID()) return var.result;
if (res.at(i).player_id == Observation()->GetPlayerID()) return res.at(i).result;
}
std::cout << "The player can not be found" << std::endl;
return sc2::GameResult::Undecided;
......
......@@ -280,7 +280,7 @@ bool MapTools::isPowered(int tileX, int tileY) const
#endif
}
float MapTools::terrainHeight(float x, float y) const
float MapTools::terrainHeightCord(float x, float y) const
{
return m_terrainHeight[(int)x][(int)y];
}
......
......@@ -47,7 +47,7 @@ public:
int width() const;
int height() const;
std::string name() const;
float terrainHeight(float x, float y) const;
float terrainHeightCord(float x, float y) const;
void drawLine(CCPositionType x1, CCPositionType y1, CCPositionType x2, CCPositionType y2, const CCColor & color = CCColor(255, 255, 255)) const;
void drawLine(const CCPosition & p1, const CCPosition & p2, const CCColor & color = CCColor(255, 255, 255)) const;
......
#include "Unit.h"
#include "IDABot.h"
#include "sc2api/sc2_gametypes.h"
Unit::Unit()
: m_bot(nullptr)
......@@ -339,30 +341,28 @@ Unit Unit::getTarget() const
if(getUnitPtr()->orders.size() > 0){
// t_id is set to the unit tag of the target
CCUnitID t_id = getUnitPtr()->orders[0].target_unit_tag;
// if it doesn't have a target. Return itself
if (m_bot->GetUnit(t_id) == nullptr) {
if (!m_bot->GetUnit(t_id).isValid()) {
return *this;
}
// IDABot finds the unit with this tag
return m_bot->GetUnit(t_id);
}
return *this;
}
bool Unit::hasTarget() const
{
{
BOT_ASSERT(isValid(), "Unit is not valid");
if (getUnitPtr()->orders.size() > 0) {
if (getUnitPtr()->orders[0].target_unit_tag != NULL) {
if (getUnitPtr()->orders[0].target_unit_tag != sc2::NullTag) {
CCUnitID t_id = getUnitPtr()->orders[0].target_unit_tag;
// IDABot finds the unit with this tag, and returns true if valid
return m_bot->GetUnit(t_id).isValid();
}
}
return false;
}
......
......@@ -3,6 +3,7 @@
#include "Common.h"
#include "UnitType.h"
class IDABot;
class Unit
......
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