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

carry now exist in IDABot

parent 32cfd745
No related branches found
No related tags found
1 merge request!7Uppdaterat API
......@@ -59,6 +59,10 @@ IDABot
Sends the string 'message' to the game chat
.. method:: IDABot.carry_vespene(self, unit) -> Boolean
"Returns true if unit carries a vespene"
Attributes:
.. autoattribute:: minerals
......
......@@ -66,24 +66,28 @@ PYBIND11_MODULE(library, m)
// IDABot is a specialization of Agent
py::class_<IDABot, PyIDABot, sc2::Agent>(m, "IDABot")
.def(py::init())
.def("on_game_start", &IDABot::OnGameStart)
.def("on_step", &IDABot::OnStep)
.def("send_chat", &IDABot::SendChat, "Send a message to the game chat", "message"_a)
.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_property_readonly("base_location_manager", &IDABot::Bases)
.def_property_readonly("tech_tree", &IDABot::GetTechTree)
.def_property_readonly("map_tools", &IDABot::Map)
.def_property_readonly("building_placer", &IDABot::GetBuildingPlacer)
.def_property_readonly("start_location", &IDABot::GetStartLocation, "CCPosition representing the start location")
.def_property_readonly("start_locations", &IDABot::GetStartLocations, "CCPosition representing the start locations")
.def_property_readonly("minerals", &IDABot::GetMinerals, "How much minerals we currently have")
.def_property_readonly("current_supply", &IDABot::GetCurrentSupply, "How much supply we are currently using")
.def_property_readonly("max_supply", &IDABot::GetMaxSupply, "How much supply we can currently use")
.def_property_readonly("gas", &IDABot::GetGas, "How much gas we currently have")
.def_property_readonly("current_frame", &IDABot::GetCurrentFrame, "Which frame we are currently on");
.def(py::init())
.def("on_game_start", &IDABot::OnGameStart)
.def("on_step", &IDABot::OnStep)
.def("send_chat", &IDABot::SendChat, "Send a message to the game chat", "message"_a)
.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("carry_vespene", &IDABot::isCarryingVespene, "If unit carries a vespene")
.def("carry_mineral", &IDABot::isCarryingMineral, "If unit carries a mineral")
.def_property_readonly("base_location_manager", &IDABot::Bases)
.def_property_readonly("tech_tree", &IDABot::GetTechTree)
.def_property_readonly("map_tools", &IDABot::Map)
.def_property_readonly("building_placer", &IDABot::GetBuildingPlacer)
.def_property_readonly("start_location", &IDABot::GetStartLocation, "CCPosition representing the start location")
.def_property_readonly("start_locations", &IDABot::GetStartLocations, "CCPosition representing the start locations")
.def_property_readonly("minerals", &IDABot::GetMinerals, "How much minerals we currently have")
.def_property_readonly("current_supply", &IDABot::GetCurrentSupply, "How much supply we are currently using")
.def_property_readonly("max_supply", &IDABot::GetMaxSupply, "How much supply we can currently use")
.def_property_readonly("gas", &IDABot::GetGas, "How much gas we currently have")
.def_property_readonly("current_frame", &IDABot::GetCurrentFrame, "Which frame we are currently on");
// API extended summer 2020
py::class_<sc2::PlayerSetup>(m, "PlayerSetup");
......
......@@ -224,3 +224,19 @@ const TypeData & IDABot::Data(const MetaType & type) const
{
return m_techTree.getData(type);
}
/*
API extended summer 2020
*/
bool IDABot::isCarryingVespene(Unit const unit) const
{
const sc2::Unit * sc2unit = unit.getUnitPtr();
return Observation()->IsUnitCarryVespene(*sc2unit);
}
bool IDABot::isCarryingMineral(Unit const unit) const
{
const sc2::Unit * sc2unit = unit.getUnitPtr();
return Observation()->IsUnitCarryMineral(*sc2unit);
}
......@@ -59,6 +59,13 @@ public:
const std::vector<Unit> GetUnits(const UnitType & type, int player = Players::Self) const;
const std::vector<CCPosition> & GetStartLocations() const;
/*
API extended summer 2020
*/
bool isCarryingVespene(Unit const unit) const;
bool isCarryingMineral(Unit const unit) const;
// Not needed, just convenience functions
const TypeData & Data(const UnitType & type) const;
const TypeData & Data(const CCUpgrade & 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