fixed instance bug with member variables
This commit is contained in:
25
crops.py
25
crops.py
@@ -41,19 +41,6 @@ ROCKET_STRATEGY = 7
|
|||||||
BOMB_STRATEGY = 5
|
BOMB_STRATEGY = 5
|
||||||
|
|
||||||
class Crops:
|
class Crops:
|
||||||
data_value_grid = []
|
|
||||||
data_coordinates = []
|
|
||||||
screenshot = []
|
|
||||||
next_level = cv.imread("crop/next_level.jpg", cv.IMREAD_COLOR)
|
|
||||||
next_level_x = cv.imread("crop/next_level_x.jpg", cv.IMREAD_COLOR)
|
|
||||||
reset_board = cv.imread("crop/reset_button.jpg", cv.IMREAD_COLOR)
|
|
||||||
reset_confirm = cv.imread("crop/reset_confirm.jpg", cv.IMREAD_COLOR)
|
|
||||||
reset_counter = 0
|
|
||||||
colors_at_standard = True
|
|
||||||
needles = {}
|
|
||||||
hsh_needles = {}
|
|
||||||
explosives = [RAINBOW, ARROW_RIGHT, ARROW_DOWN, BIGBOMB, BOMB]
|
|
||||||
colors = [GREEN, YELLOW, RED, BLUE, PURPLE, MAGINENT, CHEMTRANT, TENESENT, CIBUTRANT, ARTISENT]
|
|
||||||
|
|
||||||
def __init__(self, overlay):
|
def __init__(self, overlay):
|
||||||
self.overlay = overlay
|
self.overlay = overlay
|
||||||
@@ -62,6 +49,18 @@ class Crops:
|
|||||||
self.data_score_map = np.zeros((8, 14), dtype=int)
|
self.data_score_map = np.zeros((8, 14), dtype=int)
|
||||||
self.observation = np.zeros((8, 14), dtype=int)
|
self.observation = np.zeros((8, 14), dtype=int)
|
||||||
|
|
||||||
|
self.screenshot = []
|
||||||
|
self.next_level = cv.imread("crop/next_level.jpg", cv.IMREAD_COLOR)
|
||||||
|
self.next_level_x = cv.imread("crop/next_level_x.jpg", cv.IMREAD_COLOR)
|
||||||
|
self.reset_board = cv.imread("crop/reset_button.jpg", cv.IMREAD_COLOR)
|
||||||
|
self.reset_confirm = cv.imread("crop/reset_confirm.jpg", cv.IMREAD_COLOR)
|
||||||
|
self.reset_counter = 0
|
||||||
|
self.colors_at_standard = True
|
||||||
|
self.needles = {}
|
||||||
|
self.hsh_needles = {}
|
||||||
|
self.explosives = [RAINBOW, ARROW_RIGHT, ARROW_DOWN, BIGBOMB, BOMB]
|
||||||
|
self.colors = [GREEN, YELLOW, RED, BLUE, PURPLE, MAGINENT, CHEMTRANT, TENESENT, CIBUTRANT, ARTISENT]
|
||||||
|
|
||||||
self.current_strategy = RAINBOW_STRATEGY
|
self.current_strategy = RAINBOW_STRATEGY
|
||||||
|
|
||||||
# 230 to 2110 = 1883 / 14 = 134.5
|
# 230 to 2110 = 1883 / 14 = 134.5
|
||||||
|
|||||||
11
equipment.py
11
equipment.py
@@ -22,16 +22,17 @@ HSV_DEFAULT = HsvFilter(0, 0, 0, 179, 255, 255, 0, 0, 0, 0)
|
|||||||
|
|
||||||
|
|
||||||
class Equipment:
|
class Equipment:
|
||||||
needles = []
|
|
||||||
hsvs = []
|
|
||||||
tresholds = []
|
|
||||||
masks = []
|
|
||||||
emitters = []
|
|
||||||
|
|
||||||
def __init__(self, overlay):
|
def __init__(self, overlay):
|
||||||
self.overlay = overlay
|
self.overlay = overlay
|
||||||
self.config = UserConfigs()
|
self.config = UserConfigs()
|
||||||
|
|
||||||
|
self.needles = []
|
||||||
|
self.hsvs = []
|
||||||
|
self.tresholds = []
|
||||||
|
self.masks = []
|
||||||
|
self.emitters = []
|
||||||
|
|
||||||
self.EMITTER_TO_USE = str(overlay.emitter_use.get())
|
self.EMITTER_TO_USE = str(overlay.emitter_use.get())
|
||||||
self.SPAWN_COUNT = int(overlay.spawn_use.get())
|
self.SPAWN_COUNT = int(overlay.spawn_use.get())
|
||||||
self.ENERGY_TO_USE = int(overlay.energy_use.get())
|
self.ENERGY_TO_USE = int(overlay.energy_use.get())
|
||||||
|
|||||||
59
farm.py
59
farm.py
@@ -31,32 +31,6 @@ ARTISENT = 25
|
|||||||
|
|
||||||
|
|
||||||
class Farm:
|
class Farm:
|
||||||
data_value_grid = []
|
|
||||||
data_coordinates = []
|
|
||||||
next_level = cv.imread("farm/next_level.jpg", cv.IMREAD_COLOR)
|
|
||||||
next_level_x = cv.imread("farm/next_level_x.jpg", cv.IMREAD_COLOR)
|
|
||||||
reset_board = cv.imread("farm/reset_button.jpg", cv.IMREAD_COLOR)
|
|
||||||
reset_confirm = cv.imread("farm/reset_confirm.jpg", cv.IMREAD_COLOR)
|
|
||||||
reset_counter = 0
|
|
||||||
|
|
||||||
explosives = []
|
|
||||||
explosives.append(RAINBOW)
|
|
||||||
explosives.append(ARROW_RIGHT)
|
|
||||||
explosives.append(ARROW_DOWN)
|
|
||||||
explosives.append(BIGBOMB)
|
|
||||||
explosives.append(BOMB)
|
|
||||||
colors = []
|
|
||||||
colors.append(GREEN)
|
|
||||||
colors.append(YELLOW)
|
|
||||||
colors.append(BLUE)
|
|
||||||
colors.append(RED)
|
|
||||||
colors.append(PINK)
|
|
||||||
colors.append(MAGINENT)
|
|
||||||
colors.append(CHEMTRANT)
|
|
||||||
colors.append(TENESENT)
|
|
||||||
colors.append(CIBUTRANT)
|
|
||||||
colors.append(ARTISENT)
|
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, overlay):
|
def __init__(self, overlay):
|
||||||
self.overlay = overlay
|
self.overlay = overlay
|
||||||
@@ -64,6 +38,30 @@ class Farm:
|
|||||||
self.data_coordinates = np.zeros((8, 14), dtype=object)
|
self.data_coordinates = np.zeros((8, 14), dtype=object)
|
||||||
self.observation = np.zeros((8, 14), dtype=int)
|
self.observation = np.zeros((8, 14), dtype=int)
|
||||||
|
|
||||||
|
self.next_level = cv.imread("farm/next_level.jpg", cv.IMREAD_COLOR)
|
||||||
|
self.next_level_x = cv.imread("farm/next_level_x.jpg", cv.IMREAD_COLOR)
|
||||||
|
self.reset_board = cv.imread("farm/reset_button.jpg", cv.IMREAD_COLOR)
|
||||||
|
self.reset_confirm = cv.imread("farm/reset_confirm.jpg", cv.IMREAD_COLOR)
|
||||||
|
self.reset_counter = 0
|
||||||
|
|
||||||
|
self.explosives = []
|
||||||
|
self.explosives.append(RAINBOW)
|
||||||
|
self.explosives.append(ARROW_RIGHT)
|
||||||
|
self.explosives.append(ARROW_DOWN)
|
||||||
|
self.explosives.append(BIGBOMB)
|
||||||
|
self.explosives.append(BOMB)
|
||||||
|
self.colors = []
|
||||||
|
self.colors.append(GREEN)
|
||||||
|
self.colors.append(YELLOW)
|
||||||
|
self.colors.append(BLUE)
|
||||||
|
self.colors.append(RED)
|
||||||
|
self.colors.append(PINK)
|
||||||
|
self.colors.append(MAGINENT)
|
||||||
|
self.colors.append(CHEMTRANT)
|
||||||
|
self.colors.append(TENESENT)
|
||||||
|
self.colors.append(CIBUTRANT)
|
||||||
|
self.colors.append(ARTISENT)
|
||||||
|
|
||||||
# 230 to 2110 = 1883 / 14 = 134.5
|
# 230 to 2110 = 1883 / 14 = 134.5
|
||||||
# 60 to 1130 = 1076 / 8 = 134.5
|
# 60 to 1130 = 1076 / 8 = 134.5
|
||||||
dim = 134.5
|
dim = 134.5
|
||||||
@@ -177,8 +175,8 @@ class Farm:
|
|||||||
x1, y1, w, h = self.data_coordinates[e][i]
|
x1, y1, w, h = self.data_coordinates[e][i]
|
||||||
x2, y2 = x1 + w, y1 + h
|
x2, y2 = x1 + w, y1 + h
|
||||||
x, y = point
|
x, y = point
|
||||||
if (x1 < x and x < x2):
|
if x1 < x and x < x2:
|
||||||
if (y1 < y and y < y2):
|
if y1 < y and y < y2:
|
||||||
return e, i
|
return e, i
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
@@ -195,7 +193,6 @@ class Farm:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def get_current_board_state(self):
|
def get_current_board_state(self):
|
||||||
try:
|
|
||||||
# get an updated image of the game
|
# get an updated image of the game
|
||||||
screenshot = self.capture_window.get_screenshot()
|
screenshot = self.capture_window.get_screenshot()
|
||||||
# screenshot = cv.imread("field_farm.jpg")
|
# screenshot = cv.imread("field_farm.jpg")
|
||||||
@@ -211,10 +208,6 @@ class Farm:
|
|||||||
screenshot = self.capture_window.get_screenshot()
|
screenshot = self.capture_window.get_screenshot()
|
||||||
screenshot = screenshot[58:1134, 230:2113]
|
screenshot = screenshot[58:1134, 230:2113]
|
||||||
|
|
||||||
except:
|
|
||||||
self.capture_window.release()
|
|
||||||
print("Game window not available - shutting down application")
|
|
||||||
return None
|
|
||||||
# cv.imshow("screenshot", screenshot)
|
# cv.imshow("screenshot", screenshot)
|
||||||
# cv.waitKey(150)
|
# cv.waitKey(150)
|
||||||
# continue
|
# continue
|
||||||
|
|||||||
Reference in New Issue
Block a user