Skip to content
Snippets Groups Projects
Commit 78fff8b5 authored by David Bergström's avatar David Bergström
Browse files

Add BuildingPlacer to Python

parent ff440799
No related branches found
No related tags found
No related merge requests found
#include "library.h"
namespace py = pybind11;
void define_building_placer(py::module & m)
{
py::class_<BuildingPlacer>(m, "BuildingPlacer")
.def("can_build_here", &BuildingPlacer::canBuildHere, "x"_a, "y"_a, "unit_type"_a)
.def("can_build_here_with_spaces", &BuildingPlacer::canBuildHereWithSpace, "x"_a, "y"_a, "unit_type"_a, "build_distance"_a)
.def("get_build_location_near", &BuildingPlacer::getBuildLocationNear, "point2di"_a, "unit_type"_a, "build_distance"_a)
.def("reserve_tiles", &BuildingPlacer::reserveTiles, "x"_a, "y"_a, "width"_a, "height"_a)
.def("free_tiles", &BuildingPlacer::freeTiles, "x"_a, "y"_a, "width"_a, "height"_a)
.def("get_refinery_position", &BuildingPlacer::getRefineryPosition);
}
\ No newline at end of file
......@@ -14,6 +14,7 @@ PYBIND11_MODULE(library, m)
define_base_location(m);
define_tech_tree(m);
define_map_tools(m);
define_building_placer(m);
py::class_<Coordinator>(m, "Coordinator")
.def(py::init())
......@@ -66,6 +67,7 @@ PYBIND11_MODULE(library, m)
.def_property_readonly("base_location_manager", &IDABot::Bases)
.def_property_readonly("tech_tree", &IDABot::TechTree)
.def_property_readonly("map_tools", &IDABot::Map)
.def_property_readonly("building_placer", &IDABot::BuildingPlacer)
.def_property_readonly("start_location", &IDABot::GetStartLocation)
.def_property_readonly("minerals", &IDABot::GetMinerals)
.def_property_readonly("current_supply", &IDABot::GetCurrentSupply)
......
......@@ -7,6 +7,9 @@
#include <pybind11/stl.h> /* Automatic conversion from std::vector to Python lists */
#include <pybind11/operators.h> /* Convenient operator support */
// Lets us use "x"_a instead of py::arg("x"), great.
using namespace pybind11::literals;
// Wrapper class since the initialization uses pure argc/argv and these cannot be wrapped into Python correctly
class Coordinator : public sc2::Coordinator
{
......@@ -59,4 +62,5 @@ void define_util(pybind11::module &m);
void define_point(pybind11::module &m);
void define_base_location(pybind11::module & m);
void define_tech_tree(pybind11::module & m);
void define_map_tools(pybind11::module & m);
\ No newline at end of file
void define_map_tools(pybind11::module & m);
void define_building_placer(pybind11::module & m);
\ No newline at end of file
......@@ -656,6 +656,11 @@ void IDABot::OnError(const std::vector<sc2::ClientError> & client_errors, const
// This is called when the sc2api (Google's API) has an error.
}
BuildingPlacer & IDABot::BuildingPlacer()
{
return m_buildingPlacer;
}
const TypeData & IDABot::Data(const UnitType & type) const
{
return m_techTree.getData(type);
......
......@@ -124,6 +124,7 @@ public:
const std::vector<Unit> & GetMyUnits() const;
const std::vector<Unit> GetUnits(const UnitType & type, int player = Players::Self) const;
const std::vector<CCPosition> & GetStartLocations() const;
BuildingPlacer & BuildingPlacer();
// Not needed, just convenience functions
const TypeData & Data(const UnitType & type) 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