def METHOD_NAME(self, action):
    def _boundary_collision(sq, sp, s, osq):
        if sq[0] < 0 or sq[0] + s[0] - 1 >= self._N:
            return osq, sp * np.array([-1, 1])
        if sq[1] < 0 or sq[1] + s[1] - 1 >= self._N:
            return osq, sp * np.array([1, -1])
        return sq, sp
    # assuming sq1 and sq2 are 'safe' locations
    sq1, sq2 = self._square1, self._square2
    self._square1, self._speed1 = _boundary_collision(
        self._square1 + self._speed1, self._speed1, self._size1, sq1)
    self._square2, self._speed2 = _boundary_collision(
        self._square2 + self._speed2, self._speed2, self._size2, sq2)
    if self._collision():
        self._speed1, self._speed2 = self._speed2, self._speed1
        self._square1 = sq1
        self._square2 = sq2
    return self._obs(), 0., False, {}