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

Make TechTree available to Python

parent 7be32059
No related branches found
No related tags found
No related merge requests found
#include "library.h"
namespace py = pybind11;
void define_tech_tree(py::module & m)
{
py::class_<TypeData>(m, "TypeData")
.def_readonly("race", &TypeData::race)
.def_readonly("mineral_cost", &TypeData::mineralCost, "mineral cost of the item")
.def_readonly("gas_cost", &TypeData::gasCost, "gas cost of the item")
.def_readonly("supply_cost", &TypeData::supplyCost, "supply cost of the item")
.def_readonly("build_time", &TypeData::buildTime, "build time of the item")
.def_readonly("is_unit", &TypeData::isUnit)
.def_readonly("is_building", &TypeData::isBuilding)
.def_readonly("is_worker", &TypeData::isWorker)
.def_readonly("is_refinery", &TypeData::isRefinery)
.def_readonly("is_supply_provider", &TypeData::isSupplyProvider)
.def_readonly("is_resource_depot", &TypeData::isResourceDepot)
.def_readonly("is_addon", &TypeData::isAddon)
.def_readonly("build_ability", &TypeData::buildAbility, "the ability that creates this item")
.def_readonly("warp_ability", &TypeData::warpAbility, "the ability that creates this item via warp-in")
.def_readonly("what_builds", &TypeData::whatBuilds, "any of these units can build the item")
.def_readonly("required_units", &TypeData::requiredUnits, "owning ONE of these is required to make")
.def_readonly("required_upgrades", &TypeData::requiredUpgrades, "having ALL of these is required to make");
py::class_<TechTree>(m, "TechTree")
.def("get_data", py::overload_cast<const UnitType &>(&TechTree::getData, py::const_))
.def("get_data", py::overload_cast<const CCUpgrade &>(&TechTree::getData, py::const_));
}
\ No newline at end of file
......@@ -12,6 +12,7 @@ PYBIND11_MODULE(library, m)
define_util(m);
define_point(m);
define_base_location(m);
define_tech_tree(m);
py::class_<Coordinator>(m, "Coordinator")
.def(py::init())
......@@ -58,6 +59,7 @@ PYBIND11_MODULE(library, m)
.def("OnStep_UpdateIDABot", &IDABot::OnStep_UpdateIDABot)
.def("get_all_units", &IDABot::GetAllUnits)
.def("get_my_units", &IDABot::GetMyUnits)
.def_property_readonly("tech_tree", &IDABot::TechTree)
.def_property_readonly("base_manager", &IDABot::Bases);
py::class_<sc2::PlayerSetup>(m, "PlayerSetup");
......
......@@ -57,4 +57,5 @@ void define_unit(pybind11::module & m);
void define_unittype(pybind11::module &m);
void define_util(pybind11::module &m);
void define_point(pybind11::module &m);
void define_base_location(pybind11::module & m);
\ No newline at end of file
void define_base_location(pybind11::module & m);
void define_tech_tree(pybind11::module & m);
\ No newline at end of file
......@@ -587,6 +587,11 @@ int IDABot::GetCurrentFrame() const
return (int)Observation()->GetGameLoop();
}
const TechTree & IDABot::TechTree() const
{
return m_techTree;
}
WorkerManager & IDABot::Workers()
{
return m_workers;
......
......@@ -109,6 +109,7 @@ public:
/*
API for students
*/
const TechTree & TechTree() const;
WorkerManager & Workers();
const BaseLocationManager & Bases() const;
const MapTools & Map() 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