Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • stebr364/pycommandcenter
  • starcraft-ai-course/pycommandcenter
  • eriah592/pycommandcenter
  • edvbe696/pycommandcenter
  • dawab699/pycommandcenter
  • hanja189/pycommandcenter
  • teoga849/pycommandcenter
  • musab250/pycommandcenter
  • emibr898/pycommandcenter
  • chrgu102/pycommandcenter
  • axega544/pycommandcenter
  • edvth289/pycommandcenter
  • jonbo278/py-command-center-v-2
13 results
Show changes
Commits on Source (107)
build/
.idea
.venv
.vs
.vscode
__pycache__
.DS_Store
\ No newline at end of file
variables:
GIT_SUBMODULE_STRATEGY: recursive
image: gitlab.liu.se:5000/starcraft-ai-course/pycommandcenter
pages:
image: davidbergstrom/pycommandcenterenv
stage: deploy
stages:
- compile
- deploy
compile:
variables:
GIT_SUBMODULE_STRATEGY: recursive
stage: compile
script:
- mkdir build
- cd build
- cmake ..
- make library
- cd ../docs
- make commandcenter
artifacts:
paths:
- docs
- build
- scripts/generate_pydocs.py
expire_in: 10 minutes
only:
- master
pages:
variables:
GIT_STRATEGY: none
GIT_CHECKOUT: false
stage: deploy
script:
- cd docs
- python3 -c "import sys, os, conf, commandcenter"
- make html
- cd ..
- mkdir public
......@@ -19,3 +39,20 @@ pages:
- public
only:
- master
pack-linux:
variables:
GIT_STRATEGY: none
GIT_CHECKOUT: false
stage: deploy
script:
- cd build/python-api-src
- stubgen -m commandcenter -o .
- cd ../..
- python3 scripts/generate_pydocs.py
artifacts:
paths:
- build/python-api-src/commandcenter.cpython-312-x86_64-linux-gnu.so
- build/python-api-src/commandcenter.pyi
only:
- master
......@@ -3,7 +3,7 @@
url = https://github.com/pybind/pybind11
[submodule "lib/cpp-sc2"]
path = lib/cpp-sc2
url = https://github.com/Jackyline/cpp-sc2.git
url = https://github.com/cpp-sc2/cpp-sc2.git
[submodule "lib/sc2-gamedata"]
path = lib/sc2-gamedata
url = https://github.com/noorus/sc2-gamedata.git
......
# Extending the API
This is a guide for extending the API and adding more functionality to the courses TDDE25 and TDDD92.
If a function already exist but you can't use it in python, check and see if it's exist in the library files (pybind).
1. Create a declaration of your function in the header file.
2. Create a definition of your function in the source file.
3. Depending on which object you decided to extend, you should also add this function to the library file. The library is the pybind, making it possible to use your function in python.
4. Update the documentation. There are instructions on how you build and test the documentation.
Example:
We want to add function to unit, returning a bool depending on if it's holding a mineral. We have discovered a function in the SC2 API containing this information (sc2_client.ccp). This is a helper function, it doesn't belong to any object.
1. In unit.h: ```bool isCarryingMinerals() const;```
2. In unit.cpp: ```bool Unit::isCarryingMinerals() const
{
return sc2::IsCarryingMinerals(*m_unit);
}```
We can access m_unit in the unit file and with sc2::Function() we can access any function in the blizzard API that doesn't belong to any object. The same goes for any object, for example sc2::Point3D makes us able to access the Point3D object.
3. In lib_unit.cpp: ```.def_property_readonly("is_carrying_minerals", &Unit::isCarryingMinerals)```
4. In the folder named docs we update the documentation. In this case, we update the file unit.rst.
Common problems:
1. The return in python is a memory address:
Make sure that it returns a correct type.
2. The compiler complains about files I have not even touched:
Make sure that the startUp is library and you have release x64. If you just added a new function in pybind, check it.
MIT License
Copyright (c) 2018 David Bergström
Copyright (c) 2024 Daniel de Leng
Copyright (c) 2018 Jonas Kvarnström, David Bergström
Copyright (c) 2017 David Churchill
Permission is hereby granted, free of charge, to any person obtaining a copy
......
......@@ -23,7 +23,7 @@ Key differences:
``` python
import os
from library import *
from commandcenter import *
class MyAgent(IDABot):
......@@ -63,63 +63,85 @@ if __name__ == "__main__":
First you need to make sure you got all the build dependencies:
* cmake
* Visual Studio 2017 or later (earlier might work, but untested)
* cmake, installed at C:\Program Files\CMake
* Visual Studio 2022
* git
* python 3.7 or later (earlier might work, but untested)
* python 3.12
If you ever want to make any changes to the library, e.g. adding new features or making bug fixes, it's easier to fork the project before cloning the repository. For instructions on how to fork, see [the gitlab documentation](https://gitlab.liu.se/help/gitlab-basics/fork-project.md).
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.liu.se/course-starcraft-ai/pycommandcenter.git`
1. Open up a terminal, download the source code using the command: `git clone --recurse-submodules https://gitlab.liu.se/starcraft-ai-course/pycommandcenter.git`
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 Visual studio solution
3. Open the Visual Studio solution located in the newly created directory
`build/`
4. The project called `library` should be selected as the default StartUp
project in the Solution Explorer (on the right side by default)
5. Change settings to Release and x64
6. Click "Local Windows Debugger" and it will start compiling
7. Visual Studio will open an error message telling you it cannot open the
resulting library file, which means it **successfully** created the library
file. The file will be located at `build\python-api-src\Release` and its
called `scripts\create-visual-studio-solution-python312.bat`.
3. The file will be located at `build\python-api-src\Release` and its
name will depend on the python version used.
# How to build (Linux, untested)
# How to build (Linux)
Same dependencies applies as for Windows, although you don't need Visual
Studio.
1. Open up a terminal, download the source code using the command: `git clone --recurse-submodules https://gitlab.liu.se/course-starcraft-ai/pycommandcenter.git`
1. Open up a terminal, download the source code using the command: `git clone --recurse-submodules https://gitlab.liu.se/starcraft-ai-course/pycommandcenter.git`
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
library.
3. Run `make` to build the project (use `make -j N` if you want to use N
threads)
# Create autocomplete stub
Make sure you have mypy installed. This can be done with:
```terminal
pip3 install -r requirements.txt
```
Navigate to where your commandcenter.pyd/so is located then run:
```terminal
stubgen -m commandcenter -o .
```
NOTE: stubgen might not work on windows unless you have an active python venv.
After creating the .pyi file run the generate_pydocs.py file according to the instructions in that file.
# How to use the library with PyCharm
See [separate page](pycharm.md).
Start by downloading the library. Click the latest tag in the [PyCommandCenter repository](https://gitlab.liu.se/starcraft-ai-course/pycommandcenter/-/tags) and find a `.pyd` link at the bottom of the tag page.
Place the library in your repository.
Add the library to the Python path in Python by:
1. File->Settings->Project: (project name)->Project Interpreter.
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.
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".
# Building the documentation
1. Build the library binary as described above, the documentation uses the
binary to automate some parts
2. Install [Sphinx](http://www.sphinx-doc.org)
This can be done with:
```terminal
pip3 install -r requirements.txt
```
3. Go to the `docs` subfolder,
4. If you are **not** running Visual Studio and building in Release mode you
have to change row 17 of [conf.py](docs/conf.py) to match the location
of the resulting `pyd` file
5. Build the documentation:
* If you are using Windows, open a terminal, navigate to the docs/ folder
and run the command `make.bat html`.
and run the command `python -m sphinx . _build` (alternatively: `make.bat html`).
* If you are using Linux, open a terminal, navigate to the docs/ folder and
run the command `make html`
# Credits
PyCommandCenter is written and maintained for Linköping University through various contributors over the years. In alphabetical ordering, these include: Sofia Abaied, Dawid Lukasz Abucewicz, Anton Andell, Erik Ahlroth, David Bergström, Edvin Bergström, Jonas Bonnaudet, Emil Brynielsson, Stefan Brynielsson, Ludvig Fors, Hannes Jämtner, Jonas Kvarnström, Daniel de Leng, Fredrik Präntare, Gabriel Tofvesson, David Warnquist, Jonathan Öhrling. Feedback was provided by the teachers and students of TDDD63, TDDE25, and TDDD92.
CommandCenter is written by [David Churchill](http://www.cs.mun.ca/~dchurchill/), Assistant Professor of [Computer Science](https://www.cs.mun.ca/) at Memorial University, and organizer of the [AIIDE StarCraft AI
Competition](http://www.cs.mun.ca/~dchurchill/starcraftaicomp/).
......
# Sets up a Ubuntu 24.04 LTS environment with Python 3.12 suitable for building PyCommandCenter and its documentation
FROM ubuntu:24.04
LABEL org.opencontainers.image.authors="daniel.de.leng@liu.se"
RUN apt update && apt install -y build-essential cmake python3-full python3-pybind11 python3-pip python3-sphinx python3-sphinx-design
RUN pip3 install mypy==1.10.0 --break-system-packages # Workaround for python3-mypy having outdated version <1.10.0
ENV HOME=/root
WORKDIR /root
_autosummary/
_build/
venv
.idea
{% extends "!layout.html" %}
{% block menu %}
{{ super() }}
<a href="py-modindex.html">modindex</a>
{% endblock %}
\ No newline at end of file
......@@ -12,17 +12,21 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
# Two paths here to work on both Windows and Linux
import sys,os
sys.path.append(os.path.join(os.getcwd(), "..", "build", "python-api-src", "Release"))
sys.path.append(os.path.join(os.getcwd(), "..", "build", "python-api-src"))
sys.path.append(os.getcwd())
# -- Project information -----------------------------------------------------
project = 'PyCommandCenter'
copyright = '2018, David Bergström'
author = 'David Bergström'
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
version = ''
version = '2.0'
# The full version, including alpha/beta/rc tags
release = ''
......@@ -39,7 +43,10 @@ release = ''
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.githubpages',
'sphinx.ext.autosummary'
'sphinx.ext.autosummary',
'sphinx.ext.napoleon',
'sphinx_design',
'enum_doc',
]
autodoc_docstring_signature=True
......@@ -62,7 +69,7 @@ master_doc = 'index'
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = 'en'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
......
language: en
sphinx: true
extensions:
- sphinx_panels
default_domain: py
consecutive_numbering: true
colon_fences: true
dollar_math: true
conversions:
sphinx_panels.dropdown.DropdownDirective: parse_all
\ No newline at end of file
......@@ -10,10 +10,10 @@ Player constants
The following constants are used when referring to a player:
.. autoclass:: library.PLAYER_SELF
.. autoclass:: library.PLAYER_ENEMY
.. autoclass:: library.PLAYER_NEUTRAL
.. autoclass:: library.PLAYER_ALLY
.. autoclass:: commandcenter.PLAYER_SELF
.. autoclass:: commandcenter.PLAYER_ENEMY
.. autoclass:: commandcenter.PLAYER_NEUTRAL
.. autoclass:: commandcenter.PLAYER_ALLY
These are internally represented as integers, but these constants should be
used instead to avoid confusion.
......@@ -21,28 +21,24 @@ used instead to avoid confusion.
Difficulty
----------
.. autoclass:: library.Difficulty
.. autoclass:: commandcenter.Difficulty
:members:
:undoc-members:
AIBuild
-------
.. autoclass:: library.AIBuild
.. autoclass:: commandcenter.AIBuild
:members:
:undoc-members:
Race
----
.. class:: library.Race
.. autoclass:: commandcenter.Race
:members:
:undoc-members:
The following three values represent actual races:
.. attribute:: Race.Protoss
.. attribute:: Race.Terran
.. attribute:: Race.Zerg
The following attribute means a randomly selected race from the three above:
.. attribute:: Race.Random
.. toctree::
\ No newline at end of file
......@@ -38,6 +38,27 @@ The source code for all additional dependencies (including pybind11) are registe
The system is built using cmake, see the file `CMakeLists.txt <https://gitlab.liu.se/starcraft-ai-course/pycommandcenter/blob/master/CMakeLists.txt>`_ in the project root.
If a function already exist but you can't use it in python, check and see if it's exist in the library files (pybind).
#. Create a declaration of your function in the header file.
#. Create a definition of your function in the source file.
#. Depending on which object you decided to extend, you should also add this function to the library file. The library is the pybind, making it possible to use your function in python.
#. Update the documentation. There are instructions on how you build and test the documentation.
Example:
We want to add function to unit, returning a bool depending on if it's holding a mineral. We have discovered a function in the SC2 API containing this information (sc2_client.ccp). This is a helper function, it doesn't belong to any object.
#. In unit.h: bool isCarryingMinerals() const;
#. In unit.cpp: bool Unit::isCarryingMinerals() const { return sc2::IsCarryingMinerals(\*m_unit); }
#. We can access m_unit in the unit file and with sc2::Function() we can access any function in the blizzard API that doesn't belong to any object. The same goes for any object, for example sc2::Point3D makes us able to access the Point3D object.
#. In lib_unit.cpp: .def_property_readonly("is_carrying_minerals", &Unit::isCarryingMinerals)
#. In the folder named docs we update the documentation. In this case, we update the file unit.rst.
Common problems:
#. The return in python is a memory address: Make sure that it returns a correct type.
#. The compiler complains about files I have not even touched: Make sure that the startUp is library and you have release x64. If you just added a new function in pybind, check it.
#. The bot crashes whit a exit code -1073741819 (0xC0000005): Make sure that you dont read null values.
Document the new features / changes you have made
-------------------------------------------------
......@@ -61,3 +82,5 @@ Read the comments on your merge request and make the necessary changes
In this step someone will review your changes and make comments. These comments might ask you to make changes to the code or documentation. These changes must be done before the merge request is accepted. Therefore it is important to make merge requests several days before eventual deadlines.
Once the merge request has been accepted the code is now part of PyCommandCenter. Congratulations and thank you for your contribution to the project!
.. toctree::
\ No newline at end of file
......@@ -2,14 +2,21 @@ Coordinates
===========
The library uses 2 types of coordinate classes. One for integers and one for
floats, these are called :class:`library.Point2DI` and
:class:`library.Point2D`.
floats, these are called :class:`commandcenter.Point2DI` and
:class:`commandcenter.Point2D`. Conversion between the two types is possible by
sending the other type as argument in the constructor. In the case of
Point2D to Point2DI the floating point values will just be cast into
integer values.
Both of the types are hashable so they can be used in sets and dictionaries.
Note that it is the tuple (x_val, y_val) that will be hashed so don't mix
those sets or dictionaries with normal tuples.
Point2DI
--------
.. class:: library.Point2DI
.. class:: commandcenter.Point2DI
These points are used for defining the location of tiles, which are used when
placing buildings in Starcraft.
......@@ -21,7 +28,7 @@ Point2DI
Point2D
-------
.. class:: library.Point2D
.. class:: commandcenter.Point2D
Instances of this class is used to represent the location of Units and
support many operations for general purpose calculation.
......@@ -31,7 +38,7 @@ Example
.. code:: python
from library import Point2D, Point2DI
from commandcenter import Point2D, Point2DI
# Creating two points
......@@ -66,7 +73,7 @@ below:
.. code:: python
from math import sqrt
from library import Point2D
from commandcenter import Point2D
p1 = Point2D(3, 4)
p2 = Point2D(1, 2)
......@@ -81,3 +88,4 @@ below:
print(p1.distance(p2)) # prints: 2.8284...
.. toctree::
\ No newline at end of file
#!/bin/bash
scp -r _build/html/. davbe125@remote-und.ida.liu.se:/wwwpub/davbe125/sc2
"""
Self built extension to remove the "Members" section of enums from the autodoc output.
"""
def setup(app):
app.connect('autodoc-process-docstring', filter_autodoc_members)
def filter_autodoc_members(app, what, name, obj, options, lines):
new_lines = []
for line in lines:
if "Members:" in line:
break
else:
new_lines.append(line)
lines[:] = new_lines
\ No newline at end of file
......@@ -17,7 +17,7 @@ and more.
import os
from typing import Optional
from library import *
from commandcenter import *
class MyAgent(IDABot):
......@@ -56,7 +56,7 @@ Now, let us break it down piece by piece to understand it.
.. code-block:: python
from library import *
from commandcenter import *
This imports everything from the library into your namespace.
......@@ -74,7 +74,7 @@ Next, we need to define our bot.
def on_step(self):
IDABot.on_step(self)
A bot which plays Starcraft is defined as a subclass to the class :class:`library.IDABot` which
A bot which plays Starcraft is defined as a subclass to the class :class:`commandcenter.IDABot` which
contains some help code in order to make implementing your bit more straightforward.
If we look closer at our newly created bot, it has three methods which are all
......@@ -150,3 +150,4 @@ to:
where ``SomeOtherBot`` is a bot defined in the same way as ``MyAgent``.
.. toctree::
\ No newline at end of file
......@@ -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.
......@@ -10,61 +10,46 @@ decision-making to the user of the API.
Here is a full list of all managers:
* :class:`library.BaseLocationManager`
* :class:`library.TechTree`
* :class:`library.MapTools`
* :class:`library.BuildingPlacer`
* :class:`commandcenter.BaseLocationManager`
* :class:`commandcenter.TechTree`
* :class:`commandcenter.MapTools`
* :class:`commandcenter.BuildingPlacer`
The rest of this page contains a brief description of each manager.
BaseLocationManager
-------------------
.. class:: library.BaseLocationManager
.. class:: commandcenter.BaseLocationManager
.. attribute:: library.BaseLocationManager.base_locations
.. autoattribute:: base_locations
A list of all :class:`library.BaseLocation` on the current map
.. autoattribute:: starting_base_locations
.. attribute:: library.BaseLocationManager.starting_base_locations
.. automethod:: get_occupied_base_locations
A list of all :class:`library.BaseLocation` on the current map which a player
started at, indexed by Player constant (see :ref:`playerconstants`).
.. automethod:: get_player_starting_base_location
.. automethod:: library.BaseLocationManager.get_occupied_base_locations
.. automethod:: library.BaseLocationManager.get_player_starting_base_location
.. automethod:: library.BaseLocationManager.get_next_expansion
.. automethod:: get_next_expansion
BaseLocation
~~~~~~~~~~~~
.. class:: library.BaseLocation
.. class:: commandcenter.BaseLocation
Closely related to BaseLocationManager. This is the datastructure used by
the BaseLocationManager to keep track of all base locations and related
information.
.. attribute:: library.BaseLocation.position
The position of the center of the BaseLocation, defined as a :class:`library.Point2D`.
.. attribute:: library.BaseLocation.depot_position
.. autoattribute:: position
A suitable position for building a town hall (Command Center, Hatchery or
Nexus), defined as a :class:`library.Point2DI`.
.. autoattribute:: mineral_fields
.. autoattribute:: depot_position
.. autoattribute:: minerals
.. autoattribute:: geysers
.. automethod:: get_ground_distance
This function uses BFS and moves in a vertical and horizontal position. Because of this,
the distance might overshoot compared to calculating it with Pythagoras' theorem.
.. automethod:: is_occupied_by_player
......@@ -76,27 +61,16 @@ BaseLocation
TechTree
--------
.. class:: library.TechTree
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
used to look-up unit types properties:
.. autoclass:: commandcenter.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`_.
Instead of using TechTree, it's possible to use the functions in UnitType for
structure, etc. In IDABot there is functions for getting data about upgrades.
.. method:: get_data(argument) -> library.TypeData
Argument is either an instance of the class :class:`library.UnitType` or
an instance of the class :class:`library.CCUpgrade`, depending on what
information is wanted.
.. automethod:: get_data(argument) -> commandcenter.TypeData
.. _link: https://github.com/BurnySc2/sc2-techtree
.. _here: https://github.com/noorus/sc2-gamedata
......@@ -105,7 +79,7 @@ TechTree
TypeData
~~~~~~~~
.. autoclass:: library.TypeData
.. autoclass:: commandcenter.TypeData
:members:
:undoc-members:
......@@ -115,54 +89,15 @@ TypeData
MapTools
--------
.. autoclass:: library.MapTools
.. autoclass:: commandcenter.MapTools
:members:
:undoc-members:
This class contains two types of methods:
* Methods for drawing information to the screen
* Methods for extracting information about the map
First, let us look at the method concerning drawing information to the
screen. Methods with the suffix ``_screen`` takes percentages of the
screens height and width, i.e. values between 0 and 1. Methods without
this suffix uses the same coordinate system as the game, i.e. world
coordinates.
The top three methods below takes in a Point2D, but it's possible to
send in x and y as floats instead of Point2D.
.. automethod:: draw_box
.. automethod:: draw_circle
.. automethod:: draw_line
.. automethod:: draw_text
.. automethod:: draw_text_screen
These are methods which are useful for extracting information about the
game map:
.. automethod:: can_build_type_at_position
.. automethod:: get_closest_tiles_to
.. automethod:: get_distance_map
.. automethod:: get_ground_distance
.. automethod:: get_least_recently_seen_tile
.. autoattribute:: height
.. autoattribute:: width
.. automethod:: is_buildable
.. automethod:: is_connected
.. automethod:: is_depot_buildable_tile
.. automethod:: is_explored
.. automethod:: is_powered
.. automethod:: is_valid_position
.. automethod:: is_valid_tile
.. automethod:: is_visible
.. automethod:: is_walkable
Color
~~~~~
.. autoclass:: library.Color
.. autoclass:: commandcenter.Color
:members:
:undoc-members:
......@@ -171,19 +106,16 @@ Color
DistanceMap
~~~~~~~~~~~
.. autoclass:: library.DistanceMap
.. autoclass:: commandcenter.DistanceMap
:members:
:undoc-members:
BuildingPlacer
--------------
.. autoclass:: library.BuildingPlacer
.. autoclass:: commandcenter.BuildingPlacer
:members:
:undoc-members:
This class is useful for placing all buildings, except refineries and town halls (Command Centers, Hacheries and Nexus).
If you want to place a town hall, take a look at attribute `depot_location` of :class:`library.BaseLocation`.
If you want to place a refinery, take a look at attribute `geysers` of :class:`library.BaseLocation` and the method build_target of :class:`library.Unit`.
.. toctree::
IDABot
======
.. class:: library.IDABot
This is the basis of your bot. It contains all available managers and some
methods to get you started.
.. autoclass:: commandcenter.IDABot
See :ref:`this page <gettingstarted>` for how to properly
inherit from IDABot.
Instances of managers:
.. attribute:: IDABot.base_location_manager
An instance of the class :class:`library.BaseLocationManager`
.. attribute:: IDABot.tech_tree
An instance of the class :class:`library.TechTree`
.. attribute:: IDABot.map_tools
An instance of the class :class:`library.MapTools`
.. attribute:: IDABot.building_placer
An instance of the class :class:`library.BuildingPlacer`
.. autoattribute:: base_location_manager
.. autoattribute:: tech_tree
.. autoattribute:: map_tools
.. autoattribute:: building_placer
Inherited methods:
.. method:: IDABot.on_game_start(self)
This method when Starcraft has stared, when you inherit it you have to
call the parent's on_game_start method in order to make it work (see
:ref:`gettingstarted`).
This method is run when the game starts. See :ref:`gettingstarted`
for an example.
.. method:: IDABot.on_step(self)
This method is run on every tick of the game, when you inherit it you
have to call the parent's on_step method in order to make it work (see
:ref:`gettingstarted`).
.. method:: IDABot.on_game_end(self)
Methods:
.. method:: IDABot.get_all_units(self) -> List[library.Unit]
Retrieves a list of all visible units
.. method:: IDABot.get_my_units(self) -> List[library.Unit]
Retrieves a list of all your visible units
.. method:: IDABot.get_player_race(self) -> library.Race
Returns the players race, useful if you play Race.Random
.. method:: IDABot.send_chat(self, message)
Sends the string 'message' to the game chat
.. method:: IDABot.has_creep(self, Point2D) -> Boolean
Returns if the position has a creep
This method is run whenever the match ends.
.. method:: IDABot.move_camera(self, Point2DI)
Methods:
Move the camera to the position
.. automethod:: get_all_units
.. automethod:: get_my_units
.. automethod:: get_player_race
.. automethod:: send_chat
.. automethod:: has_creep
.. automethod:: move_camera
.. automethod:: save_replay
.. method:: IDABot.ability_for_upgrade(self, UpgradeID)
Ability that researches this upgrade
.. method:: IDABot.upgrade_mineral_cost(self, UpgradeID)
Mineral cost of researching the upgrade
.. method:: IDABot.upgrade_gas_cost(self, UpgradeID)
Example: If we send in UPGRADE_ID.BANSHEECLOAK, it will return
ABILITY_ID.RESEARCH_BANSHEECLOAKINGFIELD. In this case,
the unit of scv has the ability for this. You can then use the
unit.ability(AbilityID) on the scv for creating the upgrade.
Vespene/gas cost of researching the upgrade
.. method:: IDABot.upgrade_research_time(self, UpgradeID)
Time in GameLoops to research this upgrade
.. automethod:: upgrade_mineral_cost
.. automethod:: upgrade_gas_cost
.. automethod:: upgrade_research_time
.. automethod:: effect_radius
Attributes:
.. autoattribute:: minerals
.. autoattribute:: gas
.. autoattribute:: current_supply
.. autoattribute:: max_supply
.. autoattribute:: current_frame
.. autoattribute:: start_location
,, autoattribute:: start_locations
Debug
-----
When developing AI-methods or when simply having a problem.
The debug-methods are a great tool for speeding up the process.
.. method:: IDABot.debug_create_unit(self, UnitTypeID, Point2D, Player Constant, Int)
This method creates the nr (INT) of units on the position of the Point2D, the unit
belongs to the Player Constant
.. method:: IDABot.debug_kill_unit(self, Unit)
Kills the unit
.. method:: IDABot.debug_show_map(self)
Make the entire map visible
.. method:: IDABot.debug_fast_build(self)
Set the build time in game to 1
.. method:: IDABot.debug_enemy_control(self)
Gives the player full control over the enemy
.. method:: IDABot.debug_fast_build(self)
Set the build time in game to 1
.. method:: IDABot.debug_ignore_food(self)
Ignore food in game
.. method:: IDABot.debug_ignore_resource_cost(self)
Ignore the resource cost in game. Everything cost 0 resources
.. method:: IDABot.debug_give_all_resources(self)
Set the mineral and vespene gas to 5000
.. method:: IDABot.debug_god_mode(self)
Give yourself god mode in the game
.. method:: IDABot.debug_ignore_mineral(self)
Ignore the mineral cost in the game
.. method:: IDABot.debug_no_cooldowns(self)
Deactivate cooldowns (Basically setting them to 0)
.. method:: IDABot.debug_give_all_tech(self)
Give yourself all tech
.. method:: IDABot.debug_give_all_upgrades(self)
Give yourself all upgrades
.. method:: IDABot.debug_set_score(self, Float)
Set the player score in game
.. method:: IDABot.debug_end_game(self, Boolean)
End the game, if the Boolean is True then victory.
If False, defeat.
.. class:: commandcenter.IDABot
When developing AI-methods or when simply having a problem.
The debug-methods are a great tool for speeding up the process.
.. automethod:: debug_create_unit
.. automethod:: debug_kill_unit
.. automethod:: IDABot.debug_show_map(self)
.. automethod:: IDABot.debug_fast_build(self)
.. automethod:: debug_enemy_control
.. automethod:: debug_fast_build
.. automethod:: debug_ignore_food
.. automethod:: debug_ignore_resource_cost
.. automethod:: debug_give_all_resources
.. automethod:: debug_god_mode
.. automethod:: debug_ignore_mineral
.. automethod:: debug_no_cooldowns
.. automethod:: debug_give_all_tech
.. automethod:: debug_give_all_upgrades
.. automethod:: debug_set_score
.. automethod:: debug_end_game
.. method:: IDABot.debug_set_energy(self, Float, Unit)
Set the amount (Float) of energy to the unit
.. method:: IDABot.debug_set_life(self, Float, Unit)
Set the amount (Float) of energy to the :class:`commandcenter.Unit`
The maximum depends on the unit maxenergy.
Note: This is not in percent of the unit energy.
Same goes for life and shields.
Set the amount (Float) of life to the unit
.. automethod:: debug_set_life
.. method:: IDABot.debug_set_shields(self, Float, Unit)
.. automethod:: debug_set_shields
Set the amount (Float) of shield to the unit
.. toctree::
IDAReplayObserver
=================
.. class:: commandcenter.IDAReplayObserver
This is a class for following a replay.
Inherited methods:
.. method:: on_game_start(self)
This method is called when a replay has started, when you inherit it you have to
call the parent's on_game_start method in order to make it work (see
:ref:`replays`).
.. method:: on_step(self)
This method is called on every tick of the replay, when you inherit it you
have to call the parent's on_step method in order to make it work (see
:ref:`replays`).
.. method:: on_game_end(self)
This method is called when the replay has ended, when you inherit it you have to
call the parent's on_game_start method in order to make it work (see
:ref:`replays`).
.. method:: on_unit_created(self)
This method is called when the an unit is created, that includes when an unit leaves a refinery. This only works if replay perspective is not set to 0.
.. method:: on_unit_destroyed(self)
This unit is called when a unit is destroyed.
Methods:
.. method:: get_all_units(self) -> List[commandcenter.ReplayUnit]
Retrieves a list of all visible units.
.. method:: get_player_race(self, player_id) -> commandcenter.Race
Returns the player's race.
.. toctree::