trees.py
def move_point(self, point: Tuple[int, int], direction: str, steps: int) \
            -> Optional[Tuple[int, int]]:
        """ Return the new location of the player at point <point> after moving
        it in the given <direction> by <steps> steps.

        Raise an OutOfBoundsError if this would move the player at point
        <point> out of bounds (before moving the player).

        Raise an OutOfBoundsError if moving the player would place the player at
        exactly the same coordinates of another player in the Tree (before
        moving the player).

        Moving a point may require the tree to be reorganized. This method
        should do the minimum amount of tree reorganization possible to move the
        given point properly. (if the new point will be added to the same node
        that the old point removed from, change the _point attribute of this
        node directly.)

        if a player with at that point does not exist in the tree, the method
        fail silently without making any changes to the tree.

        Runtime: O(log(n))

        === precondition ===
        direction in ['N', 'S', 'E', 'W']

        >>> tree = TwoDTree((0, 0), (500, 500))
        >>> tree.insert('a', (250, 250))
        >>> tree.insert('b', (150, 150))
        >>> 'a' in tree
        True
        >>> tree.move_point((250, 250), 'N', 50)
        (250, 200)
        >>> 'a' in tree
        True
        >>> tree.contains_point((250, 200))
        True
        >>> tree.__getattribute__('_point')
        (250, 200)
        """
        if self.contains_point(point):
            name = self._find_name(point)
            x2, y2 = point
            if steps == 0:
                return point
            if direction == 'N':
                y2 -= steps
            elif direction == 'S':
                y2 += steps
            elif direction == 'E':
                x2 += steps
            else:
                x2 -= steps
            if x2 < self._nw[0] or x2 > self._se[0] or y2 < self._nw[1] or \
                    y2 > self._se[1] or self.contains_point((x2, y2)):
                raise OutOfBoundsError
            check = self._check_side(point[0], point[1], x2, y2, name)
            if not check:
                self.remove_point(point)
                self.insert(name, (x2, y2))
            return x2, y2
 Return the new location of the player at point <point> after moving
        it in the given <direction> by <steps> steps.

        Raise an OutOfBoundsError if this would move the player at point
        <point> out of bounds (before moving the player).

        Raise an OutOfBoundsError if moving the player would place the player at
        exactly the same coordinates of another player in the Tree (before
        moving the player).

        Moving a point may require the tree to be reorganized. This method
        should do the minimum amount of tree reorganization possible to move the
        given point properly. (if the new point will be added to the same node
        that the old point removed from, change the _point attribute of this
        node directly.)

        if a player with at that point does not exist in the tree, the method
        fail silently without making any changes to the tree.

        Runtime: O(log(n))

        === precondition ===
        direction in ['N', 'S', 'E', 'W']

        >>> tree = TwoDTree((0, 0), (500, 500))
        >>> tree.insert('a', (250, 250))
        >>> tree.insert('b', (150, 150))
        >>> 'a' in tree
        True
        >>> tree.move_point((250, 250), 'N', 50)
        (250, 200)
        >>> 'a' in tree
        True
        >>> tree.contains_point((250, 200))
        True
        >>> tree.__getattribute__('_point')
        (250, 200)
        
Return the new location of the player at point  after moving
it in the given  by  steps.

Raise an OutOfBoundsError if this would move the player at point
 out of bounds (before moving the player).

Raise an OutOfBoundsError if moving the player would place the player at
exactly the same coordinates of another player in the Tree (before
moving the player).

Moving a point may require the tree to be reorganized. This method
should do the minimum amount of tree reorganization possible to move the
given point properly. (if the new point will be added to the same node
that the old point removed from, change the _point attribute of this
node directly.)

if a player with at that point does not exist in the tree, the method
fail silently without making any changes to the tree.






Return the new location of the player at point after moving it in the given by steps . Raise an OutOfBoundsError if this would move the player at point out of bounds ( before moving the player ) . Raise an OutOfBoundsError if moving the player would place the player at exactly the same coordinates of another player in the Tree ( before moving the player ) . Moving a point may require the tree to be reorganized . This method should do the minimum amount of tree reorganization possible to move the given point properly . ( if the new point will be added to the same node that the old point removed from change the _point attribute of this node directly . ) if a player with at that point does not exist in the tree the method fail silently without making any changes to the tree .
def move_point(self, point: Tuple[int, int], direction: str, steps: int) \
            -> Optional[Tuple[int, int]]:
        if self.contains_point(point):
            name = self._find_name(point)
            x2, y2 = point
            if steps == 0:
                return point
            if direction == 'N':
                y2 -= steps
            elif direction == 'S':
                y2 += steps
            elif direction == 'E':
                x2 += steps
            else:
                x2 -= steps
            if x2 < self._nw[0] or x2 > self._se[0] or y2 < self._nw[1] or \
                    y2 > self._se[1] or self.contains_point((x2, y2)):
                raise OutOfBoundsError
            check = self._check_side(point[0], point[1], x2, y2, name)
            if not check:
                self.remove_point(point)
                self.insert(name, (x2, y2))
            return x2, y2
def move_point ( self , point : Tuple [ int , int ] , direction : str , steps : int ) -> Optional [ Tuple [ int , int ] ] : if self . contains_point ( point ) : name = self . _find_name ( point ) x2 , y2 = point if steps == 0 : return point if direction == 'N' : y2 -= steps elif direction == 'S' : y2 += steps elif direction == 'E' : x2 += steps else : x2 -= steps if x2 < self . _nw [ 0 ] or x2 > self . _se [ 0 ] or y2 < self . _nw [ 1 ] or y2 > self . _se [ 1 ] or self . contains_point ( ( x2 , y2 ) ) : raise OutOfBoundsError check = self . _check_side ( point [ 0 ] , point [ 1 ] , x2 , y2 , name ) if not check : self . remove_point ( point ) self . insert ( name , ( x2 , y2 ) ) return x2 , y2
Return the new location of the player at point <point> after moving
it in the given <direction> by <steps> steps.
Return the new location of the player at point <point > after moving it in the given <direction > by <steps > steps .
""" Return the new location of the player at point <point> after moving
        it in the given <direction> by <steps> steps.

        Raise an OutOfBoundsError if this would move the player at point
        <point> out of bounds (before moving the player).

        Raise an OutOfBoundsError if moving the player would place the player at
        exactly the same coordinates of another player in the Tree (before
        moving the player).

        Moving a point may require the tree to be reorganized. This method
        should do the minimum amount of tree reorganization possible to move the
        given point properly. (if the new point will be added to the same node
        that the old point removed from, change the _point attribute of this
        node directly.)

        if a player with at that point does not exist in the tree, the method
        fail silently without making any changes to the tree.

        Runtime: O(log(n))

        === precondition ===
        direction in ['N', 'S', 'E', 'W']

        >>> tree = TwoDTree((0, 0), (500, 500))
        >>> tree.insert('a', (250, 250))
        >>> tree.insert('b', (150, 150))
        >>> 'a' in tree
        True
        >>> tree.move_point((250, 250), 'N', 50)
        (250, 200)
        >>> 'a' in tree
        True
        >>> tree.contains_point((250, 200))
        True
        >>> tree.__getattribute__('_point')
        (250, 200)
        """
self
point
Tuple[int, int]
direction
str
steps
int