position.py#

class sc2.position.Pointlike(iterable=(), /)[source]#
closest(ps: Units | Iterable[Point2]) Unit | Point2[source]#

This function assumes the 2d distance is meant

Parameters:

ps (Units | Iterable[Point2])

Return type:

Unit | Point2

distance_to(target: Unit | Point2) float[source]#

Calculate a single distance from a point or unit to another point or unit

Parameters:

target (Unit | Point2)

Return type:

float

distance_to_closest(ps: Units | Iterable[Point2]) float[source]#

This function assumes the 2d distance is meant :type ps: Units | Iterable[Point2] :param ps:

Return type:

float

distance_to_furthest(ps: Units | Iterable[Point2]) float[source]#

This function assumes the 2d distance is meant

Parameters:

ps (Units | Iterable[Point2])

Return type:

float

distance_to_point2(p: Point2 | tuple[float, float]) float[source]#

Same as the function above, but should be a bit faster because of the dropped asserts and conversion.

Parameters:

p (Point2 | tuple[float, float])

Return type:

float

furthest(ps: Units | Iterable[Point2]) Unit | Pointlike[source]#

This function assumes the 2d distance is meant

Parameters:

ps (Units | Iterable[Point2]) – Units object, or iterable of Unit or Point2

Return type:

Unit | Pointlike

offset(p) Pointlike[source]#
Parameters:

p

Return type:

Pointlike

sort_by_distance(ps: Units | Iterable[Point2]) list[Point2][source]#

This returns the target points sorted as list. You should not pass a set or dict since those are not sortable. If you want to sort your units towards a point, use ‘units.sorted_by_distance_to(point)’ instead.

Parameters:

ps (Units | Iterable[Point2])

Return type:

list[Point2]

towards(p: Unit | Pointlike, distance: int | float = 1, limit: bool = False) Pointlike[source]#
Parameters:
Return type:

Pointlike

unit_axes_towards(p) Pointlike[source]#
Parameters:

p

Return type:

Pointlike

class sc2.position.Point2(iterable=(), /)[source]#
property as_PointI: PointI#

Represents points on the minimap. Values must be between 0 and 64.

static center(points: list[Point2]) Point2[source]#

Returns the central point for points in list

Parameters:

points (list[Point2])

Return type:

Point2

circle_intersection(p: Point2, r: int | float) set[Point2][source]#

self is point1, p is point2, r is the radius for circles originating in both points Used in ramp finding

Parameters:
Return type:

set[Point2]

direction_vector(other: Point2) Point2[source]#

Converts a vector to a direction that can face vertically, horizontally or diagonal or be zero, e.g. (0, 0), (1, -1), (1, 0)

Parameters:

other (Point2)

Return type:

Point2

classmethod from_proto(data) Point2[source]#
Parameters:

data

Return type:

Point2

property length: float#

This property exists in case Point2 is used as a vector.

manhattan_distance(other: Point2) float[source]#
Parameters:

other (Point2)

Return type:

float

property normalized: Point2#

This property exists in case Point2 is used as a vector.

offset(p: Point2) Point2[source]#
Parameters:

p (Point2)

Return type:

Point2

round(decimals: int) Point2[source]#

Rounds each number in the tuple to the amount of given decimals.

Parameters:

decimals (int)

Return type:

Point2

class sc2.position.Point3(iterable=(), /)[source]#
classmethod from_proto(data) Point3[source]#
Parameters:

data

Return type:

Point3

class sc2.position.Size(iterable=(), /)[source]#
class sc2.position.Rect(iterable=(), /)[source]#
classmethod from_proto(data) Rect[source]#
Parameters:

data

Return type:

Rect

property right: float#

Returns the x-coordinate of the rectangle of its right side.

property top: float#

Returns the y-coordinate of the rectangle of its top side.