# position.py

class sc2.position.Pointlike(iterable=(), /)
closest(ps)

This function assumes the 2d distance is meant

Parameters:

ps (`Union`[`Units`, `Iterable`[`Point2`]]) –

Return type:

`Union`[`Unit`, `Point2`]

distance_to(target)

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

Parameters:

target (`Union`[`Unit`, `Point2`]) –

Return type:

`float`

distance_to_closest(ps)

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

Return type:

`float`

distance_to_furthest(ps)

This function assumes the 2d distance is meant

Parameters:

ps (`Union`[`Units`, `Iterable`[`Point2`]]) –

Return type:

`float`

distance_to_point2(p)

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

Parameters:

p (`Union`[`Point2`, `Tuple`[`float`, `float`]]) –

Return type:

`float`

furthest(ps)

This function assumes the 2d distance is meant

Parameters:

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

Return type:

`Union`[`Unit`, `Pointlike`]

offset(p)
Parameters:

p

Return type:

`Pointlike`

sort_by_distance(ps)

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 (`Union`[`Units`, `Iterable`[`Point2`]]) –

Return type:

`List`[`Point2`]

towards(p, distance=1, limit=False)
Parameters:
Return type:

`Pointlike`

unit_axes_towards(p)
Parameters:

p

class sc2.position.Point2(iterable=(), /)
property as_PointI: PointI

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

static center(points)

Returns the central point for points in list

Parameters:

points (`List`[`Point2`]) –

Return type:

`Point2`

circle_intersection(p, r)

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)

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

Return type:

`Point2`

classmethod from_proto(data)
Parameters:

data

Return type:

`Point2`

property length: float

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

manhattan_distance(other)
Parameters:

other (`Point2`) –

Return type:

`float`

property normalized: Point2

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

offset(p)
Parameters:

p (`Point2`) –

Return type:

`Point2`

round(decimals)

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

Return type:

`Point2`

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

data

Return type:

`Point3`

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

data

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.