# Path: oscar/util/point.py
# class Point:
# 
#     def __init__(self, x=None, y=None):
#         self.x = x
#         self.y = y
# 
#     def squared_distance(self, other):
#         return (self.x-other.x)*(self.x-other.x) + (self.y-other.y)*(self.y-other.y)
# 
#     def distance(self, other):
#         return math.sqrt(self.squared_distance(other))
# 
#     def get_flipped(self):
#         return Point(self.y, self.x)
# 
#     def to_array(self):
#         return [self.x, self.y]
# 
#     def equals(self, other):
#         return self.x == other.x and self.y == other.y
# 
#     def difference(self, other):
#         return Point(self.x - other.x, self.y - other.y)
# 
#     def addition(self, other):
#         return Point(self.x + other.x, self.y + other.y)
# 
#     def __str__(self):
#         return "Point("+str(self.x)+","+str(self.y)+")"


import numpy as np
from oscar.util.point import Point
from oscar.constants import *
        self._location_timestamp = None
        self._width = None
        self._height = None

    def location(self, obs, shared):
        if not self._location_timestamp or self._location_timestamp != shared['env'].timestamp:
            mini_camera = obs.observation[MINIMAP][MINI_CAMERA]
            camera_y, camera_x = (mini_camera == 1).nonzero()
            self._location = Point(round(sum(camera_x)/len(camera_x)), round(sum(camera_y)/len(camera_y)))
            self._location_timestamp = shared['env'].timestamp
        return self._location

    def width(self, obs):
        if not self._width:
            mini_camera = obs.observation[MINIMAP][MINI_CAMERA]
            _, camera_x = (mini_camera == 1).nonzero()
            self._width = max(camera_x) - min(camera_x) + 1
        return self._width

    def height(self, obs):
        if not self._height:
            mini_camera = obs.observation[MINIMAP][MINI_CAMERA]
            camera_y, _ = (mini_camera == 1).nonzero()
            self._height = max(camera_y) - min(camera_y) + 1
        return self._height

    def random_target(self, obs):
        minimap_width = len(obs.observation[MINIMAP][0])
        minimap_height = len(obs.observation[MINIMAP][0][0])


# Path: oscar/util/point.py
# class Point:
# 
#     def __init__(self, x=None, y=None):
#         self.x = x
#         self.y = y
# 
#     def squared_distance(self, other):
#         return (self.x-other.x)*(self.x-other.x) + (self.y-other.y)*(self.y-other.y)
# 
#     def distance(self, other):
#         return math.sqrt(self.squared_distance(other))
# 
#     def get_flipped(self):
#         return Point(self.y, self.x)
# 
#     def to_array(self):
#         return [self.x, self.y]
# 
#     def equals(self, other):
#         return self.x == other.x and self.y == other.y
# 
#     def difference(self, other):
#         return Point(self.x - other.x, self.y - other.y)
# 
#     def addition(self, other):
#         return Point(self.x + other.x, self.y + other.y)
# 
#     def __str__(self):
#         return "Point("+str(self.x)+","+str(self.y)+")"


# Path: oscar/shared/camera.py
import numpy as np
from oscar.util.point import Point
from oscar.constants import *

        self._location_timestamp = None
        self._width = None
        self._height = None

    def location(self, obs, shared):
        if not self._location_timestamp or self._location_timestamp != shared['env'].timestamp:
            mini_camera = obs.observation[MINIMAP][MINI_CAMERA]
            camera_y, camera_x = (mini_camera == 1).nonzero()
            self._location = Point(round(sum(camera_x)/len(camera_x)), round(sum(camera_y)/len(camera_y)))
            self._location_timestamp = shared['env'].timestamp
        return self._location

    def width(self, obs):
        if not self._width:
            mini_camera = obs.observation[MINIMAP][MINI_CAMERA]
            _, camera_x = (mini_camera == 1).nonzero()
            self._width = max(camera_x) - min(camera_x) + 1
        return self._width

    def height(self, obs):
        if not self._height:
            mini_camera = obs.observation[MINIMAP][MINI_CAMERA]
            camera_y, _ = (mini_camera == 1).nonzero()
            self._height = max(camera_y) - min(camera_y) + 1
        return self._height

    def random_target(self, obs):
        minimap_width = len(obs.observation[MINIMAP][0])
        minimap_height = len(obs.observation[MINIMAP][0][0])


        loc = Point()