From 478448dc8a1d4de6b48031f03898e2a30a2eda7b Mon Sep 17 00:00:00 2001 From: Daniel de Leng <daniel.de.leng@liu.se> Date: Wed, 3 Jul 2024 15:19:32 +0200 Subject: [PATCH] Update documentation --- .gitlab-ci.yml | 2 +- docs/conf.py | 2 +- docs/deploy-ida.sh | 3 - docs/helpers.rst | 6 +- docs/idareplayobserver.rst | 6 +- docs/index.rst | 2 +- docs/replays.rst | 4 +- docs/types.rst | 12 ++-- python-api-src/lib_base_location.cpp | 15 +++-- python-api-src/lib_building_placer.cpp | 12 ++-- python-api-src/lib_map_tools.cpp | 50 ++++++++--------- python-api-src/lib_replay_unit.cpp | 60 ++++++++++---------- python-api-src/lib_tech_tree.cpp | 36 ++++++------ python-api-src/lib_unit.cpp | 74 ++++++++++++------------ python-api-src/lib_unittype.cpp | 58 +++++++++---------- python-api-src/library.cpp | 78 +++++++++++++------------- 16 files changed, 206 insertions(+), 214 deletions(-) delete mode 100644 docs/deploy-ida.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a9851e7ce..5280e2192 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,7 +30,7 @@ pages: stage: deploy script: - cd docs - - python3 library_import_check.py + - python3 -c "import sys, os, conf, commandcenter" - make html - cd .. - mkdir public diff --git a/docs/conf.py b/docs/conf.py index 17de4225d..ccb6d3a28 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -22,7 +22,7 @@ sys.path.append(os.getcwd()) # -- Project information ----------------------------------------------------- project = 'PyCommandCenter' -copyright = '2024' +copyright = '2024 Reasoning and Learning Lab, Linköping University' author = 'Sofia Abaied, Dawid Lukasz Abucewicz, Anton Andell, Erik Ahlroth, David Bergström, Edvin Bergström, Emil Brynielsson, Stefan Brynielsson, Ludvig Fors, Hannes Jämtner, Jonas Kvarnström, Daniel de Leng, Fredrik Präntare, Gabriel Tofvesson, David Warnquist, Jonathan Öhrling' # The short X.Y version diff --git a/docs/deploy-ida.sh b/docs/deploy-ida.sh deleted file mode 100644 index c9bc4d2ae..000000000 --- a/docs/deploy-ida.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -scp -r _build/html/. davbe125@remote-und.ida.liu.se:/wwwpub/davbe125/sc2 diff --git a/docs/helpers.rst b/docs/helpers.rst index 7c9085462..bc0154c18 100644 --- a/docs/helpers.rst +++ b/docs/helpers.rst @@ -2,7 +2,7 @@ Helpers ======= There are several classes related to processing information about the game -state and the input from Starcraft. All these classes are taken more or less +state and the input from StarCraft II. All these classes are taken more or less directly from the original `CommandCenter`_, but we have left all decision-making to the user of the API. @@ -66,7 +66,7 @@ TechTree This class has some invalid information by default, this can be corrected by placing the file `techtree.json` in the working directory. The `techtree.json` files are available here_, select the lastest version. - A techtree for SC2 version >=4.10 is now available (not fully tested yet), + A techtree for StarCraft II version >=4.10 is now available (not fully tested yet), this can be found under the folder data in this link_. A recent file is included in the `template repository`_. @@ -118,4 +118,4 @@ BuildingPlacer :undoc-members: -.. toctree:: \ No newline at end of file +.. toctree:: diff --git a/docs/idareplayobserver.rst b/docs/idareplayobserver.rst index 7b7fca3d2..d87c77588 100644 --- a/docs/idareplayobserver.rst +++ b/docs/idareplayobserver.rst @@ -37,12 +37,12 @@ IDAReplayObserver .. method:: IDAReplayObserver.get_all_units(self) -> List[commandcenter.ReplayUnit] - Retrieves a list of all visible units + Retrieves a list of all visible units. .. method:: IDAReplayObserver.get_player_race(self, player_id) -> commandcenter.Race - Returns the players race + Returns the player's race. -.. toctree:: \ No newline at end of file +.. toctree:: diff --git a/docs/index.rst b/docs/index.rst index aefa62827..e5131d699 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -19,7 +19,7 @@ Table of contents ----------------- .. toctree:: - :maxdepth: 3 + :maxdepth: 2 gettingstarted PyCommandCenter<_autosummary/commandcenter> diff --git a/docs/replays.rst b/docs/replays.rst index ad9f8e93d..6a8629360 100644 --- a/docs/replays.rst +++ b/docs/replays.rst @@ -92,7 +92,7 @@ that no action can be preform just observations. def main(): - coordinator = Coordinator(r"D:/StarCraft II/Versions/Base69232/SC2_x64.exe") + coordinator = Coordinator(r"D:/StarCraft II/Versions/Base<version>/SC2_x64.exe") if coordinator.load_replay_list("D:/Replays/"): observer = MyObserver() coordinator.add_replay_observer(observer) @@ -105,4 +105,4 @@ that no action can be preform just observations. if __name__ == "__main__": main() -.. toctree:: \ No newline at end of file +.. toctree:: diff --git a/docs/types.rst b/docs/types.rst index d8370a262..eb4839a94 100644 --- a/docs/types.rst +++ b/docs/types.rst @@ -2,16 +2,12 @@ Types ===== For a full list of all unit types see the enum :class:`commandcenter.UNIT_TYPEID`. -For more information about a certain unit type, the wrapper class -:class:`commandcenter.UnitType` can be used. +For more information about a certain unit type, the wrapper class :class:`commandcenter.UnitType` can be used. -For a full list of all abilities and upgrades, see :class:`commandcenter.ABILITY_ID` -, :class:`commandcenter.UPGRADE_ID` and :class:`commandcenter.EFFECT_ID` respectively. Note that these does not have any +For a full list of all abilities and upgrades, see :class:`commandcenter.ABILITY_ID`, :class:`commandcenter.UPGRADE_ID` and :class:`commandcenter.EFFECT_ID` respectively. Note that these does not have any wrapper classes for them. -If any of the ID's doesn't respond with the game. Before contacting the labassistent, check the game version -and the compatibility through Liquipedia. Some ID's might be left after a patch and is not available in -the game anymore. +If any of the ID's doesn't respond with the game. Before contacting the labassistent, check the game version and the compatibility through Liquipedia. Some ID's might be left after a patch and is not available in the game anymore. UnitType -------- @@ -58,4 +54,4 @@ EffectID is for things like ravager bile, or fungal or even a scan. :members: :undoc-members: -.. toctree:: \ No newline at end of file +.. toctree:: diff --git a/python-api-src/lib_base_location.cpp b/python-api-src/lib_base_location.cpp index 374dfaa7d..1cc8c10a0 100644 --- a/python-api-src/lib_base_location.cpp +++ b/python-api-src/lib_base_location.cpp @@ -5,23 +5,22 @@ namespace py = pybind11; void define_base_location(py::module & m) { py::class_<BaseLocation>(m, "BaseLocation") - .def_property_readonly("geysers", &BaseLocation::getGeysers, "List of geysers at base location (List of units)") - .def_property_readonly("minerals", &BaseLocation::getMinerals, "List of mineral fields at base location (List of unit), Note: also returns the empty mineralfields") - //.def_property_readonly("mineral_fields", &BaseLocation::getMinerals, "Alias for minerals in order to differentiate from harvested minerals") // This just did the same thing as minerals (above) removed to avoid confusion - .def_property_readonly("is_start_location", &BaseLocation::isStartLocation, "True if the base location is a start location, False otherwise") + .def_property_readonly("geysers", &BaseLocation::getGeysers, "List of geysers at base location (List of units).") + .def_property_readonly("minerals", &BaseLocation::getMinerals, "List of mineral fields at base location (List of unit). Note: also returns the empty mineral fields.") + .def_property_readonly("is_start_location", &BaseLocation::isStartLocation, "True if the base location is a start location, False otherwise.") .def_property_readonly("depot_position", &BaseLocation::getDepotPosition, "A suitable position for building a town hall (Command Center, Hatchery or Nexus), defined as a : class :`library.Point2DI`.") .def_property_readonly("position", &BaseLocation::getPosition, "The position of the center of the BaseLocation, defined as a :class:`commandcenter.Point2D`.") .def("get_ground_distance", py::overload_cast<const CCPosition &>(&BaseLocation::getGroundDistance, py::const_)) .def("get_ground_distance", py::overload_cast<const CCTilePosition &>(&BaseLocation::getGroundDistance, py::const_), "Returns the ground distance between the provided position and the base location. Note that this uses a BFS approach and may overshoot a bit.") - .def("is_occupied_by_player", &BaseLocation::isOccupiedByPlayer, "player constant"_a, "If the baselocation is occupied by the provided player. See :ref:`playerconstants` for more information") - .def("is_player_start_location", &BaseLocation::isPlayerStartLocation, "player_constant"_a, "If the baselocation is the start location of the provided player. See :ref:`playerconstants` for more information") - .def("contains_position", &BaseLocation::containsPosition, "If the baselocation contains the provided :class:`commandcenter.Point2D` position") + .def("is_occupied_by_player", &BaseLocation::isOccupiedByPlayer, "player constant"_a, "If the baselocation is occupied by the provided player. See :ref:`playerconstants` for more information.") + .def("is_player_start_location", &BaseLocation::isPlayerStartLocation, "player_constant"_a, "If the baselocation is the start location of the provided player. See :ref:`playerconstants` for more information.") + .def("contains_position", &BaseLocation::containsPosition, "If the baselocation contains the provided :class:`commandcenter.Point2D` position.") .doc() = R"( Represents a base location on the map. A base location is a location on the map where a player can build a base. It contains information about the resources available at the location, the position of the location, and other information. )"; py::class_<BaseLocationManager>(m, "BaseLocationManager") - .def_property_readonly("base_locations", &BaseLocationManager::getBaseLocations, py::return_value_policy::reference, "A list of all :class:`commandcenter.BaseLocation` on the current map") + .def_property_readonly("base_locations", &BaseLocationManager::getBaseLocations, py::return_value_policy::reference, "A list of all :class:`commandcenter.BaseLocation` on the current map.") .def_property_readonly("starting_base_locations", &BaseLocationManager::getStartingBaseLocations, py::return_value_policy::reference, "A list of all :class:`commandcenter.BaseLocation` on the current map which a player started at, indexed by Player constant(see :ref:`playerconstants`).") .def("get_occupied_base_locations", &BaseLocationManager::getOccupiedBaseLocations, py::return_value_policy::reference, "player_constant"_a, "Returns a list of all :class:`commandcenter.BaseLocation` that are occupied by the provided :ref:`playerconstants`.") .def("get_player_starting_base_location", &BaseLocationManager::getPlayerStartingBaseLocation, py::return_value_policy::copy, "player_constant"_a, "Returns the :class:`commandcenter.BaseLocation` that provided :ref:`playerconstants` started at.") diff --git a/python-api-src/lib_building_placer.cpp b/python-api-src/lib_building_placer.cpp index 8678cb214..83dd6b9ff 100644 --- a/python-api-src/lib_building_placer.cpp +++ b/python-api-src/lib_building_placer.cpp @@ -5,12 +5,12 @@ 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, "Returns if the provided unit_type it possible to be built at the location. Note: This function uses the width and height of the unit_type and this is not correct for addons. So to check addons please use can_build_here_with_size with a hardcoded size instead.") - .def("can_build_here_with_size", &BuildingPlacer::canBuildHereWithSize, "x"_a, "y"_a, "width"_a, "height"_a, "Checks if it is possible to build something with the provided width and height at the provided coordinates. Note: False if the it overlaps with a base location") - .def("can_build_here_with_spaces", &BuildingPlacer::canBuildHereWithSpace, "Creates a square with the help of x, y, distance_to_building and the size of the unit_type. Good approach if we later gonna make a addon to the building. Note: Does not reserve those extra tiles given by distance_to_building for the future! Note: This function uses the width and height of the unit_type and this is not correct for addons. So to check addons please use can_build_here_with_size with a hardcoded size instead.", "x"_a, "y"_a, "unit_type"_a, "distance_to_building"_a) - .def("get_build_location_near", &BuildingPlacer::getBuildLocationNear, "The search_count is how many building we should check (nearby buildings, instead of i < size, we can switch size to search_count). distance_to_building is the distance to the closest building.", "point2di"_a, "unit_type"_a, "distance_to_building"_a = 2, "search_count"_a = 1000) - .def("reserve_tiles", &BuildingPlacer::reserveTiles, "It's possible to reserve tiles, which makes it impossible to build at the position given by x and y.", "x"_a, "y"_a, "width"_a, "height"_a) - .def("free_tiles", &BuildingPlacer::freeTiles,"Free the tile (x, y) from reservation", "x"_a, "y"_a, "width"_a, "height"_a) + .def("can_build_here", &BuildingPlacer::canBuildHere, "x"_a, "y"_a, "unit_type"_a, "Returns if the provided unit_type it possible to be built at the location. Note: This function uses the width and height of the unit_type and this is not correct for add-ons. So to check addons please use can_build_here_with_size with a hardcoded size instead.") + .def("can_build_here_with_size", &BuildingPlacer::canBuildHereWithSize, "x"_a, "y"_a, "width"_a, "height"_a, "Checks if it is possible to build something with the provided width and height at the provided coordinates. Note: False if the it overlaps with a base location.") + .def("can_build_here_with_spaces", &BuildingPlacer::canBuildHereWithSpace, "Creates a square with the help of x, y, distance_to_building and the size of the unit_type. Good approach if we plan to later construct an add-on. Note: Does not reserve those extra tiles given by distance_to_building for the future. Note: This function uses the width and height of the unit_type and this is not correct for add-ons. So to check add-ons use can_build_here_with_size with a hardcoded size instead.", "x"_a, "y"_a, "unit_type"_a, "distance_to_building"_a) + .def("get_build_location_near", &BuildingPlacer::getBuildLocationNear, "The search_count represents how many building we should check (nearby buildings, instead of i < size, we can switch size to search_count). distance_to_building is the distance to the closest building.", "point2di"_a, "unit_type"_a, "distance_to_building"_a = 2, "search_count"_a = 1000) + .def("reserve_tiles", &BuildingPlacer::reserveTiles, "Reserves tiles, which makes it impossible to build at the position given by x and y.", "x"_a, "y"_a, "width"_a, "height"_a) + .def("free_tiles", &BuildingPlacer::freeTiles,"Free the tile (x, y) from reservation.", "x"_a, "y"_a, "width"_a, "height"_a) .doc() = R"( This class is useful for placing all buildings, except refineries and town halls (Command Centers, Hacheries and Nexus). diff --git a/python-api-src/lib_map_tools.cpp b/python-api-src/lib_map_tools.cpp index cc3b2be48..1734a8d74 100644 --- a/python-api-src/lib_map_tools.cpp +++ b/python-api-src/lib_map_tools.cpp @@ -18,39 +18,39 @@ void define_map_tools(py::module & m) const CCColor white{ 255, 255, 255 }; py::class_<MapTools>(m, "MapTools") - .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_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("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") - .def("draw_circle", py::overload_cast<const CCPosition &, CCPositionType, const CCColor &>(&MapTools::drawCircle, py::const_), py::arg("center"), py::arg("radius"), py::arg("color") = sc2::Colors::White, "Draws a circle with the given color with the provided point as center and the float as radius") - .def("draw_resource_sphere", &MapTools::drawResourceSphere, py::arg("center"), py::arg("radius"), py::arg("color") = sc2::Colors::White, "Draws a 3D sphere with the given color with the provided point as center and the float as radius") + .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 corner to the botom right.") + .def("draw_circle", py::overload_cast<const CCPosition &, CCPositionType, const CCColor &>(&MapTools::drawCircle, py::const_), py::arg("center"), py::arg("radius"), py::arg("color") = sc2::Colors::White, "Draws a circle with the given color with the provided point as center and the float as radius.") + .def("draw_resource_sphere", &MapTools::drawResourceSphere, py::arg("center"), py::arg("radius"), py::arg("color") = sc2::Colors::White, "Draws a 3D sphere with the given color with the provided point as center and the float as radius.") .def("draw_text", &MapTools::drawText, "position"_a, "text"_a, "color"_a = sc2::Colors::White) .def("draw_text_screen", &MapTools::drawTextScreen, "percentage_x"_a, "percentage_y"_a, "text"_a, "color"_a = sc2::Colors::White) - .def("is_valid_tile", py::overload_cast<int, int>(&MapTools::isValidTile, py::const_), "x"_a, "y"_a, "Checks if the position is valid for the map") - .def("is_valid_tile", py::overload_cast<const CCTilePosition &>(&MapTools::isValidTile, py::const_), "point_2di"_a, "Checks if the tile is valid for the map") - .def("is_valid_position", py::overload_cast<const CCPosition &>(&MapTools::isValidPosition, py::const_), "point_2d"_a, "Checks if the position is valid for the map") + .def("is_valid_tile", py::overload_cast<int, int>(&MapTools::isValidTile, py::const_), "x"_a, "y"_a, "Checks whether the position is valid for the map.") + .def("is_valid_tile", py::overload_cast<const CCTilePosition &>(&MapTools::isValidTile, py::const_), "point_2di"_a, "Checks whether the tile is valid for the map.") + .def("is_valid_position", py::overload_cast<const CCPosition &>(&MapTools::isValidPosition, py::const_), "point_2d"_a, "Checks whether the position is valid for the map.") .def("is_powered", &MapTools::isPowered, "x"_a, "y"_a) - .def("is_explored", py::overload_cast<int, int>(&MapTools::isExplored, py::const_), "x"_a, "y"_a, "Returns if the coordinates has been explored or not") - .def("is_explored", py::overload_cast<const CCPosition &>(&MapTools::isExplored, py::const_), "point2d"_a, "Returns if the coordinate has been explored or not") - .def("is_explored", py::overload_cast<const CCTilePosition &>(&MapTools::isExplored, py::const_), "point2di"_a, "Returns if the tile has been explored or not") - .def("is_connected", py::overload_cast<int, int, int, int>(&MapTools::isConnected, py::const_), "x1"_a, "y1"_a, "x2"_a, "y2"_a, "Returns if the coordinates are connected") - .def("is_connected", py::overload_cast<const CCTilePosition &, const CCTilePosition &>(&MapTools::isConnected, py::const_), "from"_a, "too"_a, "Returns if the tiles are connected") - .def("is_connected", py::overload_cast<const CCPosition &, const CCPosition &>(&MapTools::isConnected, py::const_), "from"_a, "too"_a, "Returns if the positions are of two connected tiles") - .def("is_walkable", py::overload_cast<int, int>(&MapTools::isWalkable, py::const_), "x"_a, "y"_a, "Returns if the coordinates is walkable") - .def("is_walkable", py::overload_cast<const CCTilePosition &>(&MapTools::isWalkable, py::const_), "point2di"_a, "Returns if the tile is walkable") - .def("is_buildable", py::overload_cast<int, int>(&MapTools::isBuildable, py::const_), "x"_a, "y"_a, "Return if it is possible to build at the provided coordinate") - .def("is_buildable", py::overload_cast<const CCTilePosition &>(&MapTools::isBuildable, py::const_), "point2di"_a, "Return if it is possible to build on tile") - .def("is_visible", &MapTools::isVisible, "x"_a, "y"_a, "Can you see the coordinates") - .def("can_build_type_at_position", &MapTools::canBuildTypeAtPosition, "x"_a, "y"_a, "unit_type"_a, "Is it possible to build the provided unittype at the location") - .def("is_depot_buildable_tile", &MapTools::isDepotBuildableTile, "x"_a, "y"_a, "Is it possbile do build a depot at the position") - .def("get_ground_distance", &MapTools::getGroundDistance, "Returns the ground distance between the two points. Note that this uses a BFS approach and may overshoot a bit. The function will also do the calculations with integers resulting in that sometimes when close to a wall it might return -1 even though a path is available", "from"_a, "to"_a) + .def("is_explored", py::overload_cast<int, int>(&MapTools::isExplored, py::const_), "x"_a, "y"_a, "Returns whether the coordinates has been explored or not.") + .def("is_explored", py::overload_cast<const CCPosition &>(&MapTools::isExplored, py::const_), "point2d"_a, "Returns whether the coordinate has been explored or not.") + .def("is_explored", py::overload_cast<const CCTilePosition &>(&MapTools::isExplored, py::const_), "point2di"_a, "Returns whether the tile has been explored or not.") + .def("is_connected", py::overload_cast<int, int, int, int>(&MapTools::isConnected, py::const_), "x1"_a, "y1"_a, "x2"_a, "y2"_a, "Returns whether the coordinates are connected.") + .def("is_connected", py::overload_cast<const CCTilePosition &, const CCTilePosition &>(&MapTools::isConnected, py::const_), "from"_a, "to"_a, "Returns whether the tiles are connected.") + .def("is_connected", py::overload_cast<const CCPosition &, const CCPosition &>(&MapTools::isConnected, py::const_), "from"_a, "to"_a, "Returns whether the positions are of two connected tiles.") + .def("is_walkable", py::overload_cast<int, int>(&MapTools::isWalkable, py::const_), "x"_a, "y"_a, "Returns whether the coordinates is walkable.") + .def("is_walkable", py::overload_cast<const CCTilePosition &>(&MapTools::isWalkable, py::const_), "point2di"_a, "Returns whether the tile is walkable.") + .def("is_buildable", py::overload_cast<int, int>(&MapTools::isBuildable, py::const_), "x"_a, "y"_a, "Returns whether it is possible to build at the provided coordinate.") + .def("is_buildable", py::overload_cast<const CCTilePosition &>(&MapTools::isBuildable, py::const_), "point2di"_a, "Returns whether it is possible to build on tile.") + .def("is_visible", &MapTools::isVisible, "x"_a, "y"_a, "Returns whether the location identified by the coordinates is visible.") + .def("can_build_type_at_position", &MapTools::canBuildTypeAtPosition, "x"_a, "y"_a, "unit_type"_a, "Returns whether it is possible to build the provided unittype at the location.") + .def("is_depot_buildable_tile", &MapTools::isDepotBuildableTile, "x"_a, "y"_a, "Returns whether it is possbile to build a depot at the position.") + .def("get_ground_distance", &MapTools::getGroundDistance, "Returns the ground distance between the two points. Note that this uses a BFS approach and may overshoot a bit. The function will also do the calculations with integers resulting in that sometimes when close to a wall it might return -1 even though a path is available.", "from"_a, "to"_a) .def("get_distance_map", py::overload_cast<const CCTilePosition &>(&MapTools::getDistanceMap, py::const_), "point2di"_a) .def("get_distance_map", py::overload_cast<const CCPosition &>(&MapTools::getDistanceMap, py::const_), "point2d"_a) - .def("get_closest_tiles_to", &MapTools::getClosestTilesTo, "Returns a list of positions, where the first position is the closest and the last is the furthest", "point2di"_a) - .def("get_least_recently_seen_tile", &MapTools::getLeastRecentlySeenTile, "Returns the tile that the most time has passed since it was visible") + .def("get_closest_tiles_to", &MapTools::getClosestTilesTo, "Returns a list of positions, where the first position is the closest and the last is the farthest.", "point2di"_a) + .def("get_least_recently_seen_tile", &MapTools::getLeastRecentlySeenTile, "Returns the tile for which the most time has passed since it was last visible.") .doc() = R"( This class contains two types of methods: diff --git a/python-api-src/lib_replay_unit.cpp b/python-api-src/lib_replay_unit.cpp index 321e20b73..cbca06b6a 100644 --- a/python-api-src/lib_replay_unit.cpp +++ b/python-api-src/lib_replay_unit.cpp @@ -5,42 +5,42 @@ namespace py = pybind11; void define_replay_unit(py::module & m) { py::class_<ReplayUnit>(m, "ReplayUnit") - .def_property_readonly("id", &ReplayUnit::getID, "The ID of the unit") - .def_property_readonly("unit_type", &ReplayUnit::getType, "The :class:`commandcenter.UnitType` of the unit") - .def_property_readonly("position", &ReplayUnit::getPosition, "The :class:`commandcenter.Point2D` of the unit") - .def_property_readonly("tile_position", &ReplayUnit::getTilePosition, "The :class:`commandcenter.Point2DI` of the unit") - .def_property_readonly("hit_points", &ReplayUnit::getHitPoints, "The hit points of the unit") - .def_property_readonly("shields", &ReplayUnit::getShields, "The shields of the unit") - .def_property_readonly("energy", &ReplayUnit::getEnergy, "The energy of the unit") + .def_property_readonly("id", &ReplayUnit::getID, "The ID of the unit.") + .def_property_readonly("unit_type", &ReplayUnit::getType, "The :class:`commandcenter.UnitType` of the unit.") + .def_property_readonly("position", &ReplayUnit::getPosition, "The :class:`commandcenter.Point2D` of the unit.") + .def_property_readonly("tile_position", &ReplayUnit::getTilePosition, "The :class:`commandcenter.Point2DI` of the unit.") + .def_property_readonly("hit_points", &ReplayUnit::getHitPoints, "The hit points of the unit.") + .def_property_readonly("shields", &ReplayUnit::getShields, "The shields of the unit.") + .def_property_readonly("energy", &ReplayUnit::getEnergy, "The energy of the unit.") .def_property_readonly("player", &ReplayUnit::getPlayer, "Returns the constant corresponding to player which this unit belongs to. See :ref:`playerconstants` for more information.") - .def_property_readonly("build_percentage", &ReplayUnit::getBuildPercentage, "The build percentage of the unit") - .def_property_readonly("weapon_cooldown", &ReplayUnit::getWeaponCooldown, "The weapon cooldown of the unit") - .def_property_readonly("is_completed", &ReplayUnit::isCompleted, "Whether the unit is completed, returns build_progress >= 1") - .def_property_readonly("is_being_constructed", &ReplayUnit::isBeingConstructed, "Whether the unit is being constructed, returns build_progress > 0") - .def_property_readonly("is_cloaked", &ReplayUnit::isCloaked, "Whether the unit is cloaked") - .def_property_readonly("is_flying", &ReplayUnit::isFlying, "Whether the unit is flying") - .def_property_readonly("buffs", &ReplayUnit::buffs, "Returns a list of BuffIDs representing the buffs on the unit") - .def_property_readonly("is_alive", &ReplayUnit::isAlive, "Whether the unit is alive") - .def_property_readonly("is_powered", &ReplayUnit::isPowered, "Whether the unit is powered") - .def_property_readonly("is_idle", &ReplayUnit::isIdle, "Whether the unit is idle") - .def_property_readonly("is_burrowed", &ReplayUnit::isBurrowed, "Whether the unit is burrowed") - .def_property_readonly("is_valid", &ReplayUnit::isValid, "Whether the unit is valid") - .def_property_readonly("is_training", &ReplayUnit::isTraining, "Whether the unit is training") - .def_property_readonly("is_blip", &ReplayUnit::isBlip, "Whether the unit is a blip ie a ping on the map") - .def_property_readonly("target", &ReplayUnit::getTarget, "The target of the unit") - .def_property_readonly("has_target", &ReplayUnit::hasTarget, "Whether the unit has a target") - .def_property_readonly("max_hit_points", &ReplayUnit::getMaxHitPoints, "The maximum hit points of the unit") - .def_property_readonly("progress", &ReplayUnit::getProgress, "Returns the progress of currently used ability (-1 if not using ability)") - .def_property_readonly("current_ability_id", &ReplayUnit::getCurrentAbilityID, "The AbilityID of currently used ability") - .def_property_readonly("facing", &ReplayUnit::getFacing, "Returns the direction the unit is facing") - .def_property_readonly("radius", &ReplayUnit::getRadius, "The radius of the unit") - .def_property_readonly("is_carrying_minerals", &ReplayUnit::isCarryingMinerals, "Whether the unit is carrying minerals") + .def_property_readonly("build_percentage", &ReplayUnit::getBuildPercentage, "The build percentage of the unit.") + .def_property_readonly("weapon_cooldown", &ReplayUnit::getWeaponCooldown, "The weapon cooldown of the unit.") + .def_property_readonly("is_completed", &ReplayUnit::isCompleted, "Whether the unit is completed, returns build_progress >= 1.") + .def_property_readonly("is_being_constructed", &ReplayUnit::isBeingConstructed, "Whether the unit is being constructed, returns build_progress > 0.") + .def_property_readonly("is_cloaked", &ReplayUnit::isCloaked, "Whether the unit is cloaked.") + .def_property_readonly("is_flying", &ReplayUnit::isFlying, "Whether the unit is flying.") + .def_property_readonly("buffs", &ReplayUnit::buffs, "Returns a list of BuffIDs representing the buffs on the unit.") + .def_property_readonly("is_alive", &ReplayUnit::isAlive, "Whether the unit is alive.") + .def_property_readonly("is_powered", &ReplayUnit::isPowered, "Whether the unit is powered.") + .def_property_readonly("is_idle", &ReplayUnit::isIdle, "Whether the unit is idle.") + .def_property_readonly("is_burrowed", &ReplayUnit::isBurrowed, "Whether the unit is burrowed.") + .def_property_readonly("is_valid", &ReplayUnit::isValid, "Whether the unit is valid.") + .def_property_readonly("is_training", &ReplayUnit::isTraining, "Whether the unit is training.") + .def_property_readonly("is_blip", &ReplayUnit::isBlip, "Whether the unit is a blip ie a ping on the map.") + .def_property_readonly("target", &ReplayUnit::getTarget, "The target of the unit.") + .def_property_readonly("has_target", &ReplayUnit::hasTarget, "Whether the unit has a target.") + .def_property_readonly("max_hit_points", &ReplayUnit::getMaxHitPoints, "The maximum hit points of the unit.") + .def_property_readonly("progress", &ReplayUnit::getProgress, "Returns the progress of currently used ability (-1 if not using ability).") + .def_property_readonly("current_ability_id", &ReplayUnit::getCurrentAbilityID, "The AbilityID of currently used ability.") + .def_property_readonly("facing", &ReplayUnit::getFacing, "Returns the direction the unit is facing.") + .def_property_readonly("radius", &ReplayUnit::getRadius, "The radius of the unit.") + .def_property_readonly("is_carrying_minerals", &ReplayUnit::isCarryingMinerals, "Whether the unit is carrying minerals.") .def("__hash__", [](const ReplayUnit & unit) { return std::hash<const sc2::Unit *>{}(unit.getUnitPtr()); }) .def(py::self == py::self) .def("__repr__", [](const ReplayUnit & unit) { return "<Unit of type: '" + unit.getType().getName() + "'>"; }) .doc() = R"( The ReplayUnit class is used to represent a unit in a replay of a game. - A ReplayUnit is a :class:`commandcenter.Unit` white some limitations. + A ReplayUnit is a :class:`commandcenter.Unit` with some limitations. It provides various properties and methods to access information about the unit, such as its ID, type, position, hit points, energy, and more. It is possible to use ReplayUnit as keys in a dictionary, which might be helpful for bookkeeping. )"; diff --git a/python-api-src/lib_tech_tree.cpp b/python-api-src/lib_tech_tree.cpp index fba8a4219..9184263ed 100644 --- a/python-api-src/lib_tech_tree.cpp +++ b/python-api-src/lib_tech_tree.cpp @@ -6,23 +6,23 @@ 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 in seconds (should be 32 game updates per tick, can someone verify this?)") - .def_readonly("is_unit", &TypeData::isUnit, "is the item a unit") - .def_readonly("is_building", &TypeData::isBuilding, "is the item a building") - .def_readonly("is_worker", &TypeData::isWorker, "is the item a worker") - .def_readonly("is_refinery", &TypeData::isRefinery, "is the item a refinery") - .def_readonly("is_supply_provider", &TypeData::isSupplyProvider, "is the item a supply provider") - .def_readonly("is_resource_depot", &TypeData::isResourceDepot, "is the item a resource depot") - .def_readonly("is_addon", &TypeData::isAddon, "is the item an addon") - .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 -> List[UnitType]") - .def_readonly("required_upgrades", &TypeData::requiredUpgrades, "having ALL of these is required to make -> List[UPGRADE_ID]") - .def_readonly("required_addons", &TypeData::requiredAddons, "a unit of this type must be present next to the producer -> List[UnitType]") + .def_readonly("mineral_cost", &TypeData::mineralCost, "The mineral cost of the item.") + .def_readonly("gas_cost", &TypeData::gasCost, "The gas cost of the item.") + .def_readonly("supply_cost", &TypeData::supplyCost, "The supply cost of the item.") + .def_readonly("build_time", &TypeData::buildTime, "The build time of the item in seconds (should be 32 game updates per tick).") + .def_readonly("is_unit", &TypeData::isUnit, "Whether the item is a unit.") + .def_readonly("is_building", &TypeData::isBuilding, "Whether the item is a building.") + .def_readonly("is_worker", &TypeData::isWorker, "Whether the item is a worker.") + .def_readonly("is_refinery", &TypeData::isRefinery, "Whether the item is a refinery.") + .def_readonly("is_supply_provider", &TypeData::isSupplyProvider, "Whether the item is a supply provider.") + .def_readonly("is_resource_depot", &TypeData::isResourceDepot, "Whether the item is a resource depot.") + .def_readonly("is_addon", &TypeData::isAddon, "Whether the item is an add-on.") + .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, "The units that can build the item.") + .def_readonly("required_units", &TypeData::requiredUnits, "Owning ONE of these (List[UnitType]) is required to make the item.") + .def_readonly("required_upgrades", &TypeData::requiredUpgrades, "Having ALL of these (List[UPGRADE_ID]) is required to make the item.") + .def_readonly("required_addons", &TypeData::requiredAddons, "A unit of this type (List[UnitType]) must be present next to the producer.") .doc() = R"( Allows you to get information about a unit type or upgrade. This is a read-only class. )"; @@ -30,7 +30,7 @@ void define_tech_tree(py::module & m) 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_), "Argument is either an instance of the class :class:`commandcenter.UnitType` or an instance of the class :class:`commandcenter.CCUpgrade`, depending on what information is wanted.") - .def("suppress_warnings", &TechTree::setSuppressWarnings, "Suppress type and upgrade warnings" ,"b"_a) + .def("suppress_warnings", &TechTree::setSuppressWarnings, "Suppress type and upgrade warnings." ,"b"_a) .doc() = R"( This class contains all information about units and what is required to build a certain unit and what builds it. It only has one method, which is diff --git a/python-api-src/lib_unit.cpp b/python-api-src/lib_unit.cpp index d64455231..4fe031c4a 100644 --- a/python-api-src/lib_unit.cpp +++ b/python-api-src/lib_unit.cpp @@ -5,63 +5,63 @@ namespace py = pybind11; void define_unit(py::module & m) { py::class_<Unit>(m, "Unit") - .def_property_readonly("unit_type", &Unit::getType, "The :class:`commandcenter.UnitType` of the unit") - .def_property_readonly("position", &Unit::getPosition, "The :class:`commandcenter.Point2D` of the unit") - .def_property_readonly("tile_position", &Unit::getTilePosition, "The :class:`commandcenter.Point2DI` of the unit") + .def_property_readonly("unit_type", &Unit::getType, "The :class:`commandcenter.UnitType` of the unit.") + .def_property_readonly("position", &Unit::getPosition, "The :class:`commandcenter.Point2D` of the unit.") + .def_property_readonly("tile_position", &Unit::getTilePosition, "The :class:`commandcenter.Point2DI` of the unit.") .def_property_readonly("hit_points", &Unit::getHitPoints, "Health of the unit.") .def_property_readonly("shields", &Unit::getShields, "Shield of the unit.") .def_property_readonly("energy", &Unit::getEnergy, "Energy of the unit.") - .def_property_readonly("player", &Unit::getPlayer, "Returns the constant corresponding to player which this unit belongs to. See :ref:`playerconstants` for more information") + .def_property_readonly("player", &Unit::getPlayer, "Returns the constant corresponding to player which this unit belongs to. See :ref:`playerconstants` for more information.") .def_property_readonly("id", &Unit::getID, "Returns an int to identify the unit. Note This value does not stay the same for units you lose vision of, so maybe not best idea to use as a way of keeping track of them.") .def_property_readonly("build_percentage", &Unit::getBuildPercentage, "Gives progress under construction. Range [0.0, 1.0]. 1.0 == finished.") .def_property_readonly("weapon_cooldown", &Unit::getWeaponCooldown, "Time remaining for a weapon on cooldown.") - .def_property_readonly("is_completed", &Unit::isCompleted, "Returns build_progress >= 1") - .def_property_readonly("is_being_constructed", &Unit::isBeingConstructed, "Returns (build_progress > 0 and not is_completed)") - .def_property_readonly("is_cloaked", &Unit::isCloaked, "If the unit is cloaked") + .def_property_readonly("is_completed", &Unit::isCompleted, "Returns build_progress >= 1.") + .def_property_readonly("is_being_constructed", &Unit::isBeingConstructed, "Returns (build_progress > 0 and not is_completed).") + .def_property_readonly("is_cloaked", &Unit::isCloaked, "If the unit is cloaked.") .def_property_readonly("is_flying", &Unit::isFlying, "If the unit is flying.") .def_property_readonly("buffs", &Unit::buffs, "Returns a list buffs on this unit. Only valid for this player's units.") .def_property_readonly("is_alive", &Unit::isAlive, "Whether the unit is alive or not.") .def_property_readonly("is_powered", &Unit::isPowered, "Whether the unit is powered by a pylon.") - .def_property_readonly("is_idle", &Unit::isIdle, "Wheter the unit has any orders") - .def_property_readonly("is_burrowed", &Unit::isBurrowed, "If the unit is burrowed.") - .def_property_readonly("is_valid", &Unit::isValid, "If the unit is valid") - .def_property_readonly("is_training", &Unit::isTraining, "Returns True if the unit is a building and is traing another unit.") - .def_property_readonly("is_blip", &Unit::isBlip, "Returns true if unit is a 'blip' - a ping on the map") - .def_property_readonly("target", &Unit::getTarget, "Returns target unit if one exists, otherwise return itself") - .def_property_readonly("has_target", &Unit::hasTarget, "Returns True if the target has a valid target and False otherwise") - .def_property_readonly("max_hit_points", &Unit::getMaxHitPoints, "Returns the max health") - .def_property_readonly("progress", &Unit::getProgress, "Returns the progress of currently used ability (-1 if not using ability)") - .def_property_readonly("progression_list", &Unit::getAllProgress, "Returns a list containing the progression on all the processes in order. Empty list if no process exists") - .def_property_readonly("current_ability_id", &Unit::getCurrentAbilityID, "The AbilityID of currently used ability") - .def_property_readonly("facing", &Unit::getFacing, "Direction the unit faces in radians (1 radian == 57.296 degrees)") - .def_property_readonly("radius", &Unit::getRadius, "Returns the radius of the unit") - .def_property_readonly("is_carrying_minerals", &Unit::isCarryingMinerals, "Returns if this unit is currently holding minerals") - .def_property_readonly("is_carrying_gas", &Unit::isCarryingGas, "Returns if this unit is currently holding gas") + .def_property_readonly("is_idle", &Unit::isIdle, "Whether the unit has any orders.") + .def_property_readonly("is_burrowed", &Unit::isBurrowed, "Whether the unit is burrowed.") + .def_property_readonly("is_valid", &Unit::isValid, "Whether the unit is valid") + .def_property_readonly("is_training", &Unit::isTraining, "Returns True if the unit is a building and is training another unit.") + .def_property_readonly("is_blip", &Unit::isBlip, "Returns true if unit is a 'blip' - a ping on the map.") + .def_property_readonly("target", &Unit::getTarget, "Returns target unit if one exists, otherwise return itself.") + .def_property_readonly("has_target", &Unit::hasTarget, "Returns True if the target has a valid target and False otherwise.") + .def_property_readonly("max_hit_points", &Unit::getMaxHitPoints, "Returns the max health.") + .def_property_readonly("progress", &Unit::getProgress, "Returns the progress of currently used ability (-1 if not using ability).") + .def_property_readonly("progression_list", &Unit::getAllProgress, "Returns a list containing the progression on all the processes in order. Empty list if no process exists.") + .def_property_readonly("current_ability_id", &Unit::getCurrentAbilityID, "The AbilityID of currently used ability.") + .def_property_readonly("facing", &Unit::getFacing, "Direction the unit faces in radians (1 radian == 57.296 degrees).") + .def_property_readonly("radius", &Unit::getRadius, "Returns the radius of the unit.") + .def_property_readonly("is_carrying_minerals", &Unit::isCarryingMinerals, "Returns if this unit is currently holding minerals.") + .def_property_readonly("is_carrying_gas", &Unit::isCarryingGas, "Returns if this unit is currently holding gas.") .def_property_readonly("gas_left_in_refinery", &Unit::gasLeftInGeyser, "Amount of vespene left in the the refinery.") .def_property_readonly("minerals_left_in_mineralfield", &Unit::mineralsLeftInMineralfield, "Amount of minerals if the unit is a mineral field.") - .def_property_readonly("owner", &Unit::getOwner, "Which player owns a unit. Note Not same as player. Player is from IDA implementation and owner is from sc2") + .def_property_readonly("owner", &Unit::getOwner, "Which player owns a unit. Note: Not same as player; 'player' originates from IDA implementation whilst 'owner' originates from StarCraft II.") .def_property_readonly("max_shields", &Unit::maxShields, "Max shield of the unit.") .def_property_readonly("max_energy", &Unit::maxEnergy, "Max energy of the unit.") - .def("hold_position", &Unit::holdPosition, "Unit will hold its position") - .def("patrol", py::overload_cast<const CCPosition &>(&Unit::patrol, py::const_), "Unit will patrol back and forth from its current location to the given Point2D") - .def("stop_dance", &Unit::stopDance, "Unit will Stop and dance") - .def("stop", &Unit::stop, "Unit will stop") - .def("attack_unit", &Unit::attackUnit, "Unit will attack the provided unit") + .def("hold_position", &Unit::holdPosition, "Unit will hold its position.") + .def("patrol", py::overload_cast<const CCPosition &>(&Unit::patrol, py::const_), "Unit will patrol back and forth from its current location to the given Point2D.") + .def("stop_dance", &Unit::stopDance, "Unit will Stop and dance.") + .def("stop", &Unit::stop, "Unit will stop.") + .def("attack_unit", &Unit::attackUnit, "Unit will attack the provided unit.") .def("attack_move", &Unit::attackMove, "Moves to provided Point2D location. If an enemy is seen on the way it will try to attack it. Will chase after the enemy as long as it is visible.") .def("ability", py::overload_cast<sc2::AbilityID>(&Unit::ability, py::const_)) .def("ability", py::overload_cast<sc2::AbilityID, const CCPosition &>(&Unit::ability, py::const_)) - .def("ability", py::overload_cast<sc2::AbilityID, const Unit &>(&Unit::ability, py::const_), "Call an ability directly, different abilities has different targets. Some target the unit itself (no argument), target a point (Point2D as argument) and some target a Unit (instance of Unit as argument)") + .def("ability", py::overload_cast<sc2::AbilityID, const Unit &>(&Unit::ability, py::const_), "Call an ability directly, different abilities has different targets. Some target the unit itself (no argument), target a point (Point2D as argument) and some target a Unit (instance of Unit as argument).") .def("move", py::overload_cast<const CCPosition &>(&Unit::move, py::const_)) .def("move", py::overload_cast<const CCTilePosition &>(&Unit::move, py::const_), "Move the unit to the given point, the point being an instance of either :class:`commandcenter.Point2D` or :class:`commandcenter.Point2DI`.") - .def("right_click", &Unit::rightClick, "Same as right-clicking in the game, for example making workers mine minerals") - .def("repair", &Unit::repair, "Right-clicks on the provided unit in order to repair it") - .def("build", &Unit::build, "Build unit of type building_type at given position", "building_type"_a, "position"_a) - .def("build_target", &Unit::buildTarget, "Build building_type on top of target Unit, useful for building refineries", "building_type"_a, "target"_a) - .def("train", &Unit::train, "Train unit of type", "unit_type"_a) - .def("morph", &Unit::morph, "Morph into type of unit_type", "unit_type"_a) - .def("research", &Unit::research, "Research the given :class:`commandcenter.UPGRADE_ID`", "upgrade_id"_a) - .def("is_constructing", &Unit::isConstructing, "unit_type"_a, "Returns true if the unit is currently constructing another unit of type `unit_type`. Note that `unit_type` needs to be an instance of :class:`commandcenter.UnitType`") + .def("right_click", &Unit::rightClick, "Same as right-clicking in the game, for example making workers mine minerals.") + .def("repair", &Unit::repair, "Right-clicks on the provided unit in order to repair it.") + .def("build", &Unit::build, "Build unit of type building_type at given position.", "building_type"_a, "position"_a) + .def("build_target", &Unit::buildTarget, "Build building_type on top of target Unit, useful for building refineries.", "building_type"_a, "target"_a) + .def("train", &Unit::train, "Train unit of type.", "unit_type"_a) + .def("morph", &Unit::morph, "Morph into type of unit_type.", "unit_type"_a) + .def("research", &Unit::research, "Research the given :class:`commandcenter.UPGRADE_ID`.", "upgrade_id"_a) + .def("is_constructing", &Unit::isConstructing, "unit_type"_a, "Returns true if the unit is currently constructing another unit of type `unit_type`. Note that `unit_type` needs to be an instance of :class:`commandcenter.UnitType`.") .def("__hash__", [](const Unit & unit) { return std::hash<const sc2::Unit *>{}(unit.getUnitPtr()); }) .def(py::self == py::self) .def("__repr__", [](const Unit & unit) { return "<Unit of type: '" + unit.getType().getName() + "'>"; }) diff --git a/python-api-src/lib_unittype.cpp b/python-api-src/lib_unittype.cpp index bdee80eaf..86124e51c 100644 --- a/python-api-src/lib_unittype.cpp +++ b/python-api-src/lib_unittype.cpp @@ -9,41 +9,41 @@ void define_unittype(py::module & m) return UnitType(type, bot, bot); })) .def_property_readonly("unit_typeid", [](UnitType & unit_type) { return static_cast<sc2::UNIT_TYPEID>(unit_type.getAPIUnitType()); }) - .def_property_readonly("name", &UnitType::getName, "The name of the unit as a sting.") + .def_property_readonly("name", &UnitType::getName, "The name of the unit as a string.") .def_property_readonly("race", &UnitType::getRace, "The race the unit belongs to.") .def_property_readonly("movement_speed", &UnitType::getMovementSpeed, "Movement speed of unit type.") .def_property_readonly("sight_range", &UnitType::getSightRange, "Range the unit reveals vision.") - .def_property_readonly("required_structure", &UnitType::getRequiredStructure, "Structure required to build this unit. (Or any with the same tech_alias)") - .def_property_readonly("is_valid", &UnitType::isValid, "Its a valid unit type") - .def_property_readonly("is_building", &UnitType::isBuilding, "Is this unit type a building or not") - .def_property_readonly("is_combat_unit", &UnitType::isCombatUnit, "The unit is not any of the following, worker, supply provider, building, larva, egg") - .def_property_readonly("is_supply_provider", &UnitType::isSupplyProvider, "The unit provides supply") - .def_property_readonly("is_resource_depot", &UnitType::isResourceDepot, "The unit is one of the following, hatchery, lair, hive, commandcenter, orbialtcommand, planetaryfortress, nexus") - .def_property_readonly("is_refinery", &UnitType::isRefinery, "The unit is one of the following (depending on race), refinery, assimilator, extractor") - .def_property_readonly("is_detector", &UnitType::isDetector, "Is this a unit type which is a detector unit") - .def_property_readonly("is_geyser", &UnitType::isGeyser, "Is the unit type a geyser") - .def_property_readonly("is_mineral", &UnitType::isMineral, "Is the unit type a mineralfield") - .def_property_readonly("is_worker", &UnitType::isWorker, "Is the unit type a unit which is a worker") - .def_property_readonly("is_morphed_building", &UnitType::isMorphedBuilding, "Has this building been mophed") + .def_property_readonly("required_structure", &UnitType::getRequiredStructure, "Structure required to build this unit. (Or any with the same tech_alias.)") + .def_property_readonly("is_valid", &UnitType::isValid, "Its a valid unit type.") + .def_property_readonly("is_building", &UnitType::isBuilding, "Is this unit type a building or not.") + .def_property_readonly("is_combat_unit", &UnitType::isCombatUnit, "The unit is not any of the following, worker, supply provider, building, larva, egg.") + .def_property_readonly("is_supply_provider", &UnitType::isSupplyProvider, "The unit provides supply.") + .def_property_readonly("is_resource_depot", &UnitType::isResourceDepot, "The unit is one of the following, hatchery, lair, hive, commandcenter, orbialtcommand, planetaryfortress, nexus.") + .def_property_readonly("is_refinery", &UnitType::isRefinery, "The unit is one of the following (depending on race), refinery, assimilator, extractor.") + .def_property_readonly("is_detector", &UnitType::isDetector, "Is this a unit type which is a detector unit.") + .def_property_readonly("is_geyser", &UnitType::isGeyser, "Is the unit type a geyser.") + .def_property_readonly("is_mineral", &UnitType::isMineral, "Is the unit type a mineralfield.") + .def_property_readonly("is_worker", &UnitType::isWorker, "Is the unit type a unit which is a worker.") + .def_property_readonly("is_morphed_building", &UnitType::isMorphedBuilding, "Has this building been morphed.") // Not implemented in CommandCenter //.def_property_readonly("can_attack", &UnitType::canAttack) //.def_property_readonly("can_Move", &UnitType::canMove) - .def_property_readonly("is_addon", &UnitType::isAddon, "Is this unit type a addon") - .def_property_readonly("can_attack_ground", &UnitType::canAttackGound, "True if this unit can attack ground units") - .def_property_readonly("can_attack_air", &UnitType::canAttackAir, "True if this unit can attack air units") - .def_property_readonly("attack_range", &UnitType::getAttackRange, "Returns the attack range of the unit type") - .def_property_readonly("attack_damage", &UnitType::getAttackDamage, "Returns the base attack damage of the unit type") - .def_property_readonly("tile_width", &UnitType::tileWidth, "Returns the width of the unit type") - .def_property_readonly("tile_height", &UnitType::tileHeight, "Returns the height of the unit type") - .def_property_readonly("supply_provided", &UnitType::supplyProvided, "Amount of supply provided by the unit type") - .def_property_readonly("supply_required", &UnitType::supplyRequired, "Amount of supply required for the unit type") - .def_property_readonly("mineral_price", &UnitType::mineralPrice, "Mineral price of the unit type") - .def_property_readonly("gas_price", &UnitType::gasPrice, "Gas price of the unit type") - .def_property_readonly("is_overlord", &UnitType::isOverlord, "Is this a ZERG_OVERLORD") - .def_property_readonly("is_larva", &UnitType::isLarva, "is this a ZERG_LARVA") - .def_property_readonly("is_egg", &UnitType::isEgg, "is this a ZERG_EGG") - .def_property_readonly("is_queen", &UnitType::isQueen, "is this a ZERG_QUEEN") - .def_property_readonly("is_tank", &UnitType::isTank, "is this a TERRAN_SIEGETANK or TERRAN_SIEGETANKSIEGED") + .def_property_readonly("is_addon", &UnitType::isAddon, "Is this unit type a add-on.") + .def_property_readonly("can_attack_ground", &UnitType::canAttackGound, "True if this unit can attack ground units.") + .def_property_readonly("can_attack_air", &UnitType::canAttackAir, "True if this unit can attack air units.") + .def_property_readonly("attack_range", &UnitType::getAttackRange, "Returns the attack range of the unit type.") + .def_property_readonly("attack_damage", &UnitType::getAttackDamage, "Returns the base attack damage of the unit type.") + .def_property_readonly("tile_width", &UnitType::tileWidth, "Returns the width of the unit type.") + .def_property_readonly("tile_height", &UnitType::tileHeight, "Returns the height of the unit type.") + .def_property_readonly("supply_provided", &UnitType::supplyProvided, "Amount of supply provided by the unit type.") + .def_property_readonly("supply_required", &UnitType::supplyRequired, "Amount of supply required for the unit type.") + .def_property_readonly("mineral_price", &UnitType::mineralPrice, "Mineral price of the unit type.") + .def_property_readonly("gas_price", &UnitType::gasPrice, "Gas price of the unit type.") + .def_property_readonly("is_overlord", &UnitType::isOverlord, "Is this a ZERG_OVERLORD.") + .def_property_readonly("is_larva", &UnitType::isLarva, "is this a ZERG_LARVA.") + .def_property_readonly("is_egg", &UnitType::isEgg, "is this a ZERG_EGG.") + .def_property_readonly("is_queen", &UnitType::isQueen, "is this a ZERG_QUEEN.") + .def_property_readonly("is_tank", &UnitType::isTank, "is this a TERRAN_SIEGETANK or TERRAN_SIEGETANKSIEGED.") .def_property_readonly("get_equivalent_units", &UnitType::getEquivalentUnits, "Units this is equivalent to in terms of satisfying tech requirements.") .def_property_readonly("required_attached", &UnitType::requiredAttached, "Whether tech_requirement is an add-on.") .def_property_readonly("build_time", &UnitType::getBuildTime, "How long the unit takes to build.") diff --git a/python-api-src/library.cpp b/python-api-src/library.cpp index bbb745c31..2348de060 100644 --- a/python-api-src/library.cpp +++ b/python-api-src/library.cpp @@ -130,48 +130,48 @@ PYBIND11_MODULE(commandcenter, m) .def("on_step", &IDABot::OnStep, R"(The on_step function in the IDABot class is a method that is called every game step (or frame) during a Starcraft II match. This function is crucial for implementing the bot's logic that needs to be executed continuously throughout the game. It's where the bot evaluates the current game state, makes decisions, and issues commands to units.)") - .def("send_chat", &IDABot::SendChat, "Sends the string 'message' to the game chat", "message"_a) - .def("get_all_units", &IDABot::GetAllUnits, "Returns a list of all visible units, including minerals and geysers") - .def("get_my_units", &IDABot::GetMyUnits, "Returns a list of all your units") - .def("get_player_race", &IDABot::GetPlayerRace, "Returns the players race, useful if you play Race.Random") - .def("debug_create_unit", &IDABot::DebugCreateUnit, "This method creates the nr (INT) of units on the position :class:`commandcenter.Point2D`, the unit belongs to the Player Constant", "unit_type"_a, "p"_a, "player_id"_a = 0, "count"_a = 1) - .def("debug_kill_unit", &IDABot::DebugKillUnit, "Kill the unit from debug mode") - .def("debug_show_map", &IDABot::DebugShowMap, "Show the entire map through debug mode") - .def("debug_fast_build", &IDABot::DebugFastBuild, "Set build time in game to 1 through debug mode") - .def("debug_enemy_control", &IDABot::DebugEnemyControl, "Control the enemy through debug mode") - .def("debug_ignore_food", &IDABot::DebugIgnoreFood, "Ignore the food in game through debug mode") - .def("debug_ignore_resource_cost", &IDABot::DebugIgnoreResourceCost, "Ignore the resource cost in game, making, everything cost zero resources through debug mode") - .def("debug_give_all_resources", &IDABot::DebugGiveAllResources, "Set the mineral and vespene gas to 5000 through debug mode") - .def("debug_god_mode", &IDABot::DebugGodMode, "Give the player god mode") - .def("debug_ignore_mineral", &IDABot::DebugIgnoreMineral, "Ignore the mineral cost in game through debug mode") - .def("debug_no_cooldowns", &IDABot::DebugNoCooldowns, "Deactive cooldowns (Basically setting them to 0) through debug mode") - .def("debug_give_all_tech", &IDABot::DebugGiveAllTech, "Give all the tech to the player through debug mode") - .def("debug_give_all_upgrades", &IDABot::DebugGiveAllUpgrades, "Give all the upgrades to the player through debug mode") - .def("debug_set_score", &IDABot::DebugSetScore, "Set the Players score in game through debug mode") + .def("send_chat", &IDABot::SendChat, "Sends the string 'message' to the game chat.", "message"_a) + .def("get_all_units", &IDABot::GetAllUnits, "Returns a list of all visible units, including minerals and geysers.") + .def("get_my_units", &IDABot::GetMyUnits, "Returns a list of all your units.") + .def("get_player_race", &IDABot::GetPlayerRace, "Returns the players race, useful if you play Race.Random.") + .def("debug_create_unit", &IDABot::DebugCreateUnit, "This method creates the nr (INT) of units on the position :class:`commandcenter.Point2D`, the unit belongs to the Player Constant.", "unit_type"_a, "p"_a, "player_id"_a = 0, "count"_a = 1) + .def("debug_kill_unit", &IDABot::DebugKillUnit, "Kill the unit from debug mode.") + .def("debug_show_map", &IDABot::DebugShowMap, "Show the entire map through debug mode.") + .def("debug_fast_build", &IDABot::DebugFastBuild, "Set build time in game to 1 through debug mode.") + .def("debug_enemy_control", &IDABot::DebugEnemyControl, "Control the enemy through debug mode.") + .def("debug_ignore_food", &IDABot::DebugIgnoreFood, "Ignore the food in game through debug mode.") + .def("debug_ignore_resource_cost", &IDABot::DebugIgnoreResourceCost, "Ignore the resource cost in game, making, everything cost zero resources through debug mode.") + .def("debug_give_all_resources", &IDABot::DebugGiveAllResources, "Set the mineral and vespene gas to 5000 through debug mode.") + .def("debug_god_mode", &IDABot::DebugGodMode, "Give the player god mode.") + .def("debug_ignore_mineral", &IDABot::DebugIgnoreMineral, "Ignore the mineral cost in game through debug mode.") + .def("debug_no_cooldowns", &IDABot::DebugNoCooldowns, "Deactive cooldowns (Basically setting them to 0) through debug mode.") + .def("debug_give_all_tech", &IDABot::DebugGiveAllTech, "Give all the tech to the player through debug mode.") + .def("debug_give_all_upgrades", &IDABot::DebugGiveAllUpgrades, "Give all the upgrades to the player through debug mode.") + .def("debug_set_score", &IDABot::DebugSetScore, "Set the Players score in game through debug mode.") .def("debug_end_game", &IDABot::DebugEndGame, "End the game through debug mode. If the Boolean is True then victory. If False, defeat.") - .def("debug_set_energy", &IDABot::DebugSetEnergy, "Set the energy on a unit through debug mode") - .def("debug_set_life", &IDABot::DebugSetLife, "Set the life on a unit through debug mode") - .def("debug_set_shields", &IDABot::DebugSetShields, "Set the shields on a unit through debug mode") - .def("get_enemy_base_location", &IDABot::GetEnemyBaseLocations, "Return the CCposition of the enemy base") - .def("move_camera", &IDABot::CameraMove, "Move the camera to the position", "p"_a) - .def("has_creep", &IDABot::HasCreep, "Returns true if there is creep at position p", "p"_a) - .def("ability_for_upgrade", &IDABot::abilityForUpgrade, "Ability that researches this upgrade", "upgrade"_a) - .def("upgrade_mineral_cost", &IDABot::UpgradeMineralCost, "Mineral cost of researching the upgrade", "upgrade"_a) - .def("upgrade_gas_cost", &IDABot::UpgradeGasCost, "Vespene/gas cost of researching the upgrade", "upgrade"_a) - .def("upgrade_research_time", &IDABot::UpgradeResearchTime, "Time in GameLoops to research this upgrade", "upgrade"_a) - .def("effect_radius", &IDABot::RadiusEffect, "Size of the circle the effect impacts", "effect"_a) + .def("debug_set_energy", &IDABot::DebugSetEnergy, "Set the energy on a unit through debug mode.") + .def("debug_set_life", &IDABot::DebugSetLife, "Set the life on a unit through debug mode.") + .def("debug_set_shields", &IDABot::DebugSetShields, "Set the shields on a unit through debug mode.") + .def("get_enemy_base_location", &IDABot::GetEnemyBaseLocations, "Return the CCposition of the enemy base.") + .def("move_camera", &IDABot::CameraMove, "Move the camera to the position.", "p"_a) + .def("has_creep", &IDABot::HasCreep, "Returns true if there is creep at position p.", "p"_a) + .def("ability_for_upgrade", &IDABot::abilityForUpgrade, "Ability that researches this upgrade.", "upgrade"_a) + .def("upgrade_mineral_cost", &IDABot::UpgradeMineralCost, "Mineral cost of researching the upgrade.", "upgrade"_a) + .def("upgrade_gas_cost", &IDABot::UpgradeGasCost, "Vespene/gas cost of researching the upgrade.", "upgrade"_a) + .def("upgrade_research_time", &IDABot::UpgradeResearchTime, "Time in GameLoops to research this upgrade.", "upgrade"_a) + .def("effect_radius", &IDABot::RadiusEffect, "Size of the circle the effect impacts.", "effect"_a) .def_property_readonly("base_location_manager", &IDABot::Bases, "An instance of the class :class:`commandcenter.BaseLocationManager`. ") - .def_property_readonly("tech_tree", &IDABot::GetTechTree, "An instance of the class :class:`commandcenter.TechTree`") - .def_property_readonly("map_tools", &IDABot::Map, "An instance of the class :class:`commandcenter.MapTools`") - .def_property_readonly("building_placer", &IDABot::GetBuildingPlacer, "An instance of the class :class:`commandcenter.BuildingPlacer`") + .def_property_readonly("tech_tree", &IDABot::GetTechTree, "An instance of the class :class:`commandcenter.TechTree`.") + .def_property_readonly("map_tools", &IDABot::Map, "An instance of the class :class:`commandcenter.MapTools`.") + .def_property_readonly("building_placer", &IDABot::GetBuildingPlacer, "An instance of the class :class:`commandcenter.BuildingPlacer`.") .def_property_readonly("start_location", &IDABot::GetStartLocation, "CCPosition representing the start location, note that it is the depot position that is returned.") - .def_property_readonly("start_locations", &IDABot::GetStartLocations, "List of CCPositions representing the start locations, note that it is the depot positions and not the center positions") - .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") - .doc() = R"(This is a striped down basic version of an bot. It contains all available managers and basic methods.)"; + .def_property_readonly("start_locations", &IDABot::GetStartLocations, "List of CCPositions representing the start locations, note that it is the depot positions and not the center positions.") + .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.") + .doc() = R"(This is a stripped-down version of a bot. It contains all available managers and basic methods.)"; -- GitLab