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

Add MapTools and colors

parent 8b14642b
Branches
Tags
No related merge requests found
#include "library.h"
namespace py = pybind11;
void define_map_tools(py::module & m)
{
const CCColor white{ 255, 255, 255 };
py::class_<MapTools>(m, "MapTools")
.def_property_readonly("width", &MapTools::width)
.def_property_readonly("height", &MapTools::height)
//.def("terrainHeight", &MapTools::terrainHeight, py::const_)
.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"))
//.def("draw_line", py::overload_cast<CCPositionType, CCPositionType, CCPositionType, CCPositionType, const CCColor &>(&MapTools::drawLine, py::const_)); // TODO: Default argument??
.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"))
.def("draw_circle", py::overload_cast<const CCPosition &, CCPositionType, const CCColor &>(&MapTools::drawCircle, py::const_), py::arg("center"), py::arg("radius"), py::arg("color"))
.def("draw_text", &MapTools::drawText)
.def("draw_text_screen", &MapTools::drawTextScreen);
/*
TODO: Left to implement
drawBox(CCPositionType x1, CCPositionType y1, CCPositionType x2, CCPositionType y2, const CCColor & color = CCColor(255, 255, 255)) const;
drawCircle(CCPositionType x1, CCPositionType x2, CCPositionType radius, const CCColor & color = CCColor(255, 255, 255)) const;
isValidTile(int tileX, int tileY) const;
isValidTile(const CCTilePosition & tile) const;
isValidPosition(const CCPosition & pos) const;
isPowered(int tileX, int tileY) const;
isExplored(int tileX, int tileY) const;
isExplored(const CCPosition & pos) const;
isExplored(const CCTilePosition & pos) const;
isVisible(int tileX, int tileY) const;
canBuildTypeAtPosition(int tileX, int tileY, const UnitType & type) const;
getDistanceMap(const CCTilePosition & tile) const;
getDistanceMap(const CCPosition & tile) const;
getGroundDistance(const CCPosition & src, const CCPosition & dest) const;
isConnected(int x1, int y1, int x2, int y2) const;
isConnected(const CCTilePosition & from, const CCTilePosition & to) const;
isConnected(const CCPosition & from, const CCPosition & to) const;
isWalkable(int tileX, int tileY) const;
isWalkable(const CCTilePosition & tile) const;
isBuildable(int tileX, int tileY) const;
isBuildable(const CCTilePosition & tile) const;
isDepotBuildableTile(int tileX, int tileY) const;
getLeastRecentlySeenTile() const;
// returns a list of all tiles on the map, sorted by 4-direcitonal walk distance from the given position
const std::vector<CCTilePosition> & getClosestTilesTo(const CCTilePosition & pos) const;
*/
}
\ No newline at end of file
...@@ -13,6 +13,7 @@ PYBIND11_MODULE(library, m) ...@@ -13,6 +13,7 @@ PYBIND11_MODULE(library, m)
define_point(m); define_point(m);
define_base_location(m); define_base_location(m);
define_tech_tree(m); define_tech_tree(m);
define_map_tools(m);
py::class_<Coordinator>(m, "Coordinator") py::class_<Coordinator>(m, "Coordinator")
.def(py::init()) .def(py::init())
...@@ -64,6 +65,7 @@ PYBIND11_MODULE(library, m) ...@@ -64,6 +65,7 @@ PYBIND11_MODULE(library, m)
.def("get_player_race", &IDABot::GetPlayerRace) .def("get_player_race", &IDABot::GetPlayerRace)
.def_property_readonly("base_location_manager", &IDABot::Bases) .def_property_readonly("base_location_manager", &IDABot::Bases)
.def_property_readonly("tech_tree", &IDABot::TechTree) .def_property_readonly("tech_tree", &IDABot::TechTree)
.def_property_readonly("map_tools", &IDABot::Map)
.def_property_readonly("start_location", &IDABot::GetStartLocation) .def_property_readonly("start_location", &IDABot::GetStartLocation)
.def_property_readonly("minerals", &IDABot::GetMinerals) .def_property_readonly("minerals", &IDABot::GetMinerals)
.def_property_readonly("current_supply", &IDABot::GetCurrentSupply) .def_property_readonly("current_supply", &IDABot::GetCurrentSupply)
...@@ -84,6 +86,24 @@ PYBIND11_MODULE(library, m) ...@@ -84,6 +86,24 @@ PYBIND11_MODULE(library, m)
.value("CheatMoney", sc2::Difficulty::CheatMoney) .value("CheatMoney", sc2::Difficulty::CheatMoney)
.value("CheatInsane", sc2::Difficulty::CheatInsane); .value("CheatInsane", sc2::Difficulty::CheatInsane);
py::class_<sc2::Color>(m, "Color")
.def(py::init<>())
.def(py::init<int, int, int>())
.def_readwrite("r", &sc2::Color::r)
.def_readwrite("g", &sc2::Color::g)
.def_readwrite("b", &sc2::Color::b);
py::module colors = m.def_submodule("Colors", "Constants for common colors");
colors.attr("White") = sc2::Colors::White;
colors.attr("Red") = sc2::Colors::Red;
colors.attr("Green") = sc2::Colors::Green;
colors.attr("Yellow") = sc2::Colors::Yellow;
colors.attr("Blue") = sc2::Colors::Blue;
colors.attr("Teal") = sc2::Colors::Teal;
colors.attr("Purple") = sc2::Colors::Purple;
colors.attr("Black") = sc2::Colors::Black;
colors.attr("Gray") = sc2::Colors::Gray;
m.def("create_participants", &sc2::CreateParticipant, "Create participant from agent"); m.def("create_participants", &sc2::CreateParticipant, "Create participant from agent");
m.def("create_computer", &sc2::CreateComputer, "Create participant from built-in Starcraft computer"); m.def("create_computer", &sc2::CreateComputer, "Create participant from built-in Starcraft computer");
} }
...@@ -58,4 +58,5 @@ void define_unittype(pybind11::module &m); ...@@ -58,4 +58,5 @@ void define_unittype(pybind11::module &m);
void define_util(pybind11::module &m); void define_util(pybind11::module &m);
void define_point(pybind11::module &m); void define_point(pybind11::module &m);
void define_base_location(pybind11::module & m); void define_base_location(pybind11::module & m);
void define_tech_tree(pybind11::module & m); void define_tech_tree(pybind11::module & m);
\ No newline at end of file void define_map_tools(pybind11::module & m);
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment