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

Merge LiU-gitlab version containing CI/CD support

parents 7129f351 f661b794
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,7 @@ Key differences: ...@@ -14,7 +14,7 @@ Key differences:
* Everything is built using cmake, allowing for one Visual studio project to * Everything is built using cmake, allowing for one Visual studio project to
build PyCommandCenter together with all its dependencies build PyCommandCenter together with all its dependencies
[Download page for Windows](https://gitlab.ida.liu.se/starcraft-api/pycommandcenter/tags) [Download page for Windows](https://gitlab.ida.liu.se/course-starcraft-ai/pycommandcenter/tags)
# Code example for making a bot # Code example for making a bot
...@@ -68,10 +68,10 @@ First you need to make sure you got all the build dependencies: ...@@ -68,10 +68,10 @@ First you need to make sure you got all the build dependencies:
Now, you are ready to build the python library: Now, you are ready to build the python library:
1. Open up a terminal, download the source code using the command: `git clone --recurse-submodules https://gitlab.ida.liu.se/starcraft-api/pycommandcenter.git` 1. Open up a terminal, download the source code using the command: `git clone --recurse-submodules https://gitlab.ida.liu.se/course-starcraft-ai/pycommandcenter.git`
2. Next, open the repository in your file viewer and run the batch script 2. Next, open the repository in your file viewer and run the batch script
called `create-visual-studio-solution.bat` in order to use cmake to create a called `create-visual-studio-solution.bat` in order to use cmake to create
Visual studio solution a Visual studio solution
3. Open the Visual Studio solution located in the newly created directory 3. Open the Visual Studio solution located in the newly created directory
`build/` `build/`
4. The project called `library` should be selected as the default StartUp 4. The project called `library` should be selected as the default StartUp
...@@ -88,7 +88,7 @@ Now, you are ready to build the python library: ...@@ -88,7 +88,7 @@ Now, you are ready to build the python library:
Same dependencies applies as for Windows, although you don't need Visual Same dependencies applies as for Windows, although you don't need Visual
Studio. Studio.
1. Open up a terminal, download the source code using the command: `git clone --recurse-submodules https://gitlab.ida.liu.se/starcraft-api/pycommandcenter.git` 1. Open up a terminal, download the source code using the command: `git clone --recurse-submodules https://gitlab.ida.liu.se/course-starcraft-ai/pycommandcenter.git`
2. Next, enter the directory and run the command `mkdir build` followed by `cd 2. Next, enter the directory and run the command `mkdir build` followed by `cd
build` and `cmake ..` in order to create the makefiles needed for building the build` and `cmake ..` in order to create the makefiles needed for building the
library. library.
......
...@@ -36,6 +36,6 @@ Race ...@@ -36,6 +36,6 @@ Race
.. attribute:: Race.Terran .. attribute:: Race.Terran
.. attribute:: Race.Zerg .. attribute:: Race.Zerg
This means a randomly selected race from the three above: The following attribute means a randomly selected race from the three above:
.. attribute:: Race.Random .. attribute:: Race.Random
# Installing PyCommandCenter in PyCharm # Installing PyCommandCenter in PyCharm
Start of by download the library from the [PyCommandCenter repository](https://gitlab.ida.liu.se/starcraft-api/pycommandcenter/tags). Start by downloading the library from the [PyCommandCenter repository](https://gitlab.ida.liu.se/course-starcraft-ai/pycommandcenter/tags).
Place the library in your repository. Place the library in your repository.
Add the library to the Python path in Python by: Add the library to the Python path in Python by:
1. File->Settings->Project: (project name)->Project Interpreter 1. File->Settings->Project: (project name)->Project Interpreter.
2. Select the cog in the upper right corner and select "Show All" 2. Select the cog in the upper right corner and select "Show All".
3. In the new window that opens select the icon which shows a few folders connected with lines 3. In the new window that opens, select the icon which shows a few folders connected with lines.
4. In the new window press the plus icon and select the path of your repository (should be where you placed the library) 4. In the new window, first press the plus icon, and then select the path of your repository (the path to where you placed the library).
5. Restart PyCharm with File->Invalidate Caches/Restart->Invalidate and Restart 5. Restart PyCharm with "File->Invalidate Caches/Restart->Invalidate and Restart".
\ No newline at end of file
...@@ -9,7 +9,7 @@ void define_base_location(py::module & m) ...@@ -9,7 +9,7 @@ void define_base_location(py::module & m)
.def_property_readonly("minerals", &BaseLocation::getMinerals, "List of mineral fields at base location (List of unit)") .def_property_readonly("minerals", &BaseLocation::getMinerals, "List of mineral fields at base location (List of unit)")
.def_property_readonly("mineral_fields", &BaseLocation::getMinerals, "Alias for minerals in order to differentiate from harvested minerals") .def_property_readonly("mineral_fields", &BaseLocation::getMinerals, "Alias for minerals in order to differentiate from harvested minerals")
.def_property_readonly("is_start_location", &BaseLocation::isStartLocation, "True if the base location is a start location, False otherwise") .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, "Point2DI position suitable for placing a town hall") .def_property_readonly("depot_position", &BaseLocation::getDepotPosition, "Point2DI position suitable for placing a town hall (base structure)")
.def_property_readonly("position", &BaseLocation::getPosition) .def_property_readonly("position", &BaseLocation::getPosition)
.def("get_ground_distance", py::overload_cast<const CCPosition &>(&BaseLocation::getGroundDistance, py::const_)) .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_)) .def("get_ground_distance", py::overload_cast<const CCTilePosition &>(&BaseLocation::getGroundDistance, py::const_))
......
...@@ -63,7 +63,7 @@ PYBIND11_MODULE(library, m) ...@@ -63,7 +63,7 @@ PYBIND11_MODULE(library, m)
.def(py::init()); .def(py::init());
// IDABot is a specialization of Agent // IDABot is a specialization of Agent
py::class_<IDABot, PyIDABot, sc2::Agent>(m, "IDABot") py::class_<IDABot, PyIDABot, sc2::Agent>(m, "IDABot")
.def(py::init()) .def(py::init())
.def("on_game_start", &IDABot::OnGameStart) .def("on_game_start", &IDABot::OnGameStart)
.def("on_step", &IDABot::OnStep) .def("on_step", &IDABot::OnStep)
...@@ -78,7 +78,10 @@ PYBIND11_MODULE(library, m) ...@@ -78,7 +78,10 @@ PYBIND11_MODULE(library, m)
.def_property_readonly("minerals", &IDABot::GetMinerals, "How much minerals we currently have") .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("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("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("gas", &IDABot::GetGas, "How much gas we currently have")
.def("use_ability", &IDABot::UseAbility, "Use an ability with the given unit")
.def("use_ability", &IDABot::UseAbilityWithPoint, "Use ability at point with the given unit")
.def("use_ability", &IDABot::UseAbilityWithTarget, "Use ability at target with the given unit");
py::class_<sc2::PlayerSetup>(m, "PlayerSetup"); py::class_<sc2::PlayerSetup>(m, "PlayerSetup");
......
...@@ -219,3 +219,17 @@ const TypeData & IDABot::Data(const MetaType & type) const ...@@ -219,3 +219,17 @@ const TypeData & IDABot::Data(const MetaType & type) const
return m_techTree.getData(type); return m_techTree.getData(type);
} }
void IDABot::UseAbility(const Unit& unit, sc2::AbilityID ability)
{
Actions()->UnitCommand(unit.getUnitPtr(), ability, false);
}
void IDABot::UseAbilityWithPoint(const Unit& unit, sc2::AbilityID ability, const sc2::Point2D& point)
{
Actions()->UnitCommand(unit.getUnitPtr(), ability, point, false);
}
void IDABot::UseAbilityWithTarget(const Unit& unit, sc2::AbilityID ability, const Unit* target)
{
Actions()->UnitCommand(unit.getUnitPtr(), ability, target->getUnitPtr(), false);
}
...@@ -62,4 +62,9 @@ public: ...@@ -62,4 +62,9 @@ public:
const TypeData & Data(const CCUpgrade & type) const; const TypeData & Data(const CCUpgrade & type) const;
const TypeData & Data(const MetaType & type) const; const TypeData & Data(const MetaType & type) const;
const TypeData & Data(const Unit & unit) const; const TypeData & Data(const Unit & unit) const;
// Used for giving "raw" commands to units
void UseAbility(const Unit& unit, sc2::AbilityID ability);
void UseAbilityWithPoint(const Unit& unit, sc2::AbilityID ability, const sc2::Point2D& point);
void UseAbilityWithTarget(const Unit& unit, sc2::AbilityID ability, const Unit* target);
}; };
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