added fruit game support
This commit is contained in:
24
fruit.py
24
fruit.py
@@ -86,8 +86,8 @@ class Fruit(GameBase):
|
||||
screenshot = screenshot[188:1022, 553:1861]
|
||||
# 553 to 1861 = 1330 / 11 = 119
|
||||
# 188 to 1022
|
||||
# cv.imshow("screenshot", screenshot)
|
||||
# cv.waitKey(150)
|
||||
#cv.imshow("screenshot", screenshot)
|
||||
#cv.waitKey(150)
|
||||
# continue
|
||||
data_coords = np.zeros((7, 11), dtype=object)
|
||||
# field = Field()
|
||||
@@ -125,24 +125,32 @@ class Fruit(GameBase):
|
||||
def find_patterns_and_valid_moves(self, state):
|
||||
for e in range(0, 7, 1):
|
||||
for i in range(0, 11, 1):
|
||||
for color in self.colors:
|
||||
if self.check_pairs(state, e, i, color):
|
||||
if state[e, i] in self.colors:
|
||||
#color in self.colors:
|
||||
if self.check_pairs_h(state, e, i):
|
||||
return
|
||||
if self.overlay.run_mode == 'stopped' or self.overlay.run_mode == 'paused':
|
||||
if self.check_pairs_v(state, e, i):
|
||||
return
|
||||
if self.overlay.run_mode == 'stopped' or self.overlay.run_mode == 'paused':
|
||||
return
|
||||
if self.overlay.run_mode == 'stopped' or self.overlay.run_mode == 'paused':
|
||||
return
|
||||
|
||||
def check_pairs(self, state, e, i, color):
|
||||
def check_pairs_h(self, state, e, i):
|
||||
try:
|
||||
#
|
||||
if state[e, i] == color and state[e + 1, i] == color:
|
||||
if state[e, i] == state[e + 1, i]:
|
||||
click_pt = self.get_click_point(self.data_coordinates[e, i])
|
||||
self.dig_point(click_pt[0] + self.offset_left, click_pt[1] + self.offset_down, 100)
|
||||
return True
|
||||
elif state[e, i] == color and state[e, i + 1] == color:
|
||||
return False
|
||||
except:
|
||||
return False
|
||||
|
||||
def check_pairs_v(self, state, e, i):
|
||||
try:
|
||||
#
|
||||
if state[e, i] == state[e, i + 1]:
|
||||
click_pt = self.get_click_point(self.data_coordinates[e, i])
|
||||
self.dig_point(click_pt[0] + self.offset_left, click_pt[1] + self.offset_down, 100)
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user