added color switch and reset trigger
This commit is contained in:
@@ -48,24 +48,8 @@ class Field:
|
|||||||
colors_at_standard = True
|
colors_at_standard = True
|
||||||
needles = {}
|
needles = {}
|
||||||
hsh_needles = {}
|
hsh_needles = {}
|
||||||
explosives = []
|
explosives = [RAINBOW, ARROW_RIGHT, ARROW_DOWN, BIGBOMB, BOMB]
|
||||||
explosives.append(RAINBOW)
|
colors = [GREEN, YELLOW, RED, BLUE, PURPLE, MAGINENT, CHEMTRANT, TENESENT, CIBUTRANT, ARTISENT]
|
||||||
explosives.append(ARROW_RIGHT)
|
|
||||||
explosives.append(ARROW_DOWN)
|
|
||||||
explosives.append(BIGBOMB)
|
|
||||||
explosives.append(BOMB)
|
|
||||||
colors = []
|
|
||||||
colors.append(GREEN)
|
|
||||||
colors.append(YELLOW)
|
|
||||||
colors.append(RED)
|
|
||||||
colors.append(BLUE)
|
|
||||||
colors.append(PURPLE)
|
|
||||||
|
|
||||||
colors.append(MAGINENT)
|
|
||||||
colors.append(CHEMTRANT)
|
|
||||||
colors.append(TENESENT)
|
|
||||||
colors.append(CIBUTRANT)
|
|
||||||
colors.append(ARTISENT)
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.data_value_grid = np.zeros((8, 14), dtype=int)
|
self.data_value_grid = np.zeros((8, 14), dtype=int)
|
||||||
@@ -106,12 +90,7 @@ class Field:
|
|||||||
BOMB: cv.imread("bomb.jpg", cv.IMREAD_COLOR),
|
BOMB: cv.imread("bomb.jpg", cv.IMREAD_COLOR),
|
||||||
ARROW_DOWN: cv.imread("arrow_down.jpg", cv.IMREAD_COLOR),
|
ARROW_DOWN: cv.imread("arrow_down.jpg", cv.IMREAD_COLOR),
|
||||||
ARROW_RIGHT: cv.imread("arrow_right.jpg", cv.IMREAD_COLOR),
|
ARROW_RIGHT: cv.imread("arrow_right.jpg", cv.IMREAD_COLOR),
|
||||||
# ROCK_1: cv.imread("rock1.jpg", cv.IMREAD_COLOR),
|
|
||||||
# ROCK_2: cv.imread("rock2.jpg", cv.IMREAD_COLOR),
|
|
||||||
# ROCK_3: cv.imread("rock3.jpg", cv.IMREAD_COLOR),
|
|
||||||
# BURGER: cv.imread("burger.jpg", cv.IMREAD_COLOR),
|
|
||||||
# GOLDBAR: cv.imread("burger.jpg", cv.IMREAD_COLOR),
|
|
||||||
# PAB1: cv.imread("pab1.jpg", cv.IMREAD_COLOR),
|
|
||||||
MAGINENT: cv.imread("maginent.jpg", cv.IMREAD_COLOR),
|
MAGINENT: cv.imread("maginent.jpg", cv.IMREAD_COLOR),
|
||||||
CHEMTRANT: cv.imread("chemtrant.jpg", cv.IMREAD_COLOR),
|
CHEMTRANT: cv.imread("chemtrant.jpg", cv.IMREAD_COLOR),
|
||||||
TENESENT: cv.imread("tenesent.jpg", cv.IMREAD_COLOR),
|
TENESENT: cv.imread("tenesent.jpg", cv.IMREAD_COLOR),
|
||||||
@@ -122,13 +101,15 @@ class Field:
|
|||||||
self.hsh_needles = {order[0]: HsvFilter(0, 0, 0, 179, 255, 255, 0, 0, 0, 0),
|
self.hsh_needles = {order[0]: HsvFilter(0, 0, 0, 179, 255, 255, 0, 0, 0, 0),
|
||||||
order[1]: HsvFilter(0, 0, 0, 179, 255, 255, 0, 0, 0, 0),
|
order[1]: HsvFilter(0, 0, 0, 179, 255, 255, 0, 0, 0, 0),
|
||||||
order[2]: HsvFilter(0, 0, 0, 179, 255, 255, 0, 0, 0, 0),
|
order[2]: HsvFilter(0, 0, 0, 179, 255, 255, 0, 0, 0, 0),
|
||||||
order[3]: HsvFilter(0, 0, 0, 179, 255, 255, 0, 0, 0, 0),
|
order[3]: HsvFilter(60, 40, 0, 115, 255, 255, 0, 0, 0, 0),
|
||||||
order[4]: HsvFilter(120, 45, 0, 170, 255, 255, 0, 0, 0, 0),
|
order[4]: HsvFilter(120, 45, 0, 170, 255, 255, 0, 0, 0, 0),
|
||||||
|
|
||||||
RAINBOW: HsvFilter(0, 0, 0, 179, 255, 255, 0, 0, 0, 0),
|
RAINBOW: HsvFilter(0, 0, 0, 179, 255, 255, 0, 0, 0, 0),
|
||||||
BIGBOMB: HsvFilter(0, 0, 0, 179, 255, 255, 0, 0, 0, 0),
|
BIGBOMB: HsvFilter(60, 40, 0, 179, 129, 129, 0, 0, 0, 0),
|
||||||
BOMB: HsvFilter(0, 0, 0, 179, 255, 255, 0, 0, 0, 0),
|
BOMB: HsvFilter(0, 0, 0, 179, 255, 255, 0, 0, 0, 0),
|
||||||
ARROW_DOWN: HsvFilter(0, 0, 0, 179, 255, 255, 0, 0, 0, 0),
|
ARROW_DOWN: HsvFilter(0, 0, 0, 179, 255, 255, 0, 0, 0, 0),
|
||||||
ARROW_RIGHT: HsvFilter(0, 0, 0, 179, 255, 255, 0, 0, 0, 0),
|
ARROW_RIGHT: HsvFilter(0, 0, 0, 179, 255, 255, 0, 0, 0, 0),
|
||||||
|
|
||||||
MAGINENT: HsvFilter(0, 0, 0, 179, 255, 255, 0, 0, 0, 0),
|
MAGINENT: HsvFilter(0, 0, 0, 179, 255, 255, 0, 0, 0, 0),
|
||||||
CHEMTRANT: HsvFilter(0, 0, 0, 179, 255, 255, 0, 0, 0, 0),
|
CHEMTRANT: HsvFilter(0, 0, 0, 179, 255, 255, 0, 0, 0, 0),
|
||||||
TENESENT: HsvFilter(0, 0, 0, 179, 255, 255, 0, 0, 0, 0),
|
TENESENT: HsvFilter(0, 0, 0, 179, 255, 255, 0, 0, 0, 0),
|
||||||
@@ -187,14 +168,14 @@ class Field:
|
|||||||
def change_value(self, x, y, val):
|
def change_value(self, x, y, val):
|
||||||
self.data_value_grid[x][y] = val
|
self.data_value_grid[x][y] = val
|
||||||
|
|
||||||
def pointInRect(self, point):
|
def point_in_rect(self, point):
|
||||||
for e in range(0, 8, 1):
|
for e in range(0, 8, 1):
|
||||||
for i in range(0, 14, 1):
|
for i in range(0, 14, 1):
|
||||||
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
|
||||||
|
|
||||||
@@ -249,7 +230,7 @@ class Field:
|
|||||||
points = self.vision_stun.get_click_points(rectangles)
|
points = self.vision_stun.get_click_points(rectangles)
|
||||||
|
|
||||||
for point in points:
|
for point in points:
|
||||||
x, y = self.pointInRect(point)
|
x, y = self.point_in_rect(point)
|
||||||
if x is not None and y is not None:
|
if x is not None and y is not None:
|
||||||
data_coords[x][y] = int(needle_key)
|
data_coords[x][y] = int(needle_key)
|
||||||
# self.change_value(x, y, int(needle_key))
|
# self.change_value(x, y, int(needle_key))
|
||||||
@@ -329,20 +310,16 @@ class Field:
|
|||||||
if self.check_explosives(state, x, y):
|
if self.check_explosives(state, x, y):
|
||||||
return
|
return
|
||||||
if self.data_score_map[x, y] >= 4:
|
if self.data_score_map[x, y] >= 4:
|
||||||
path_option = []
|
path_option = [[x, y]]
|
||||||
path_option.append([x, y])
|
recursion_reminder = [[x, y]]
|
||||||
recursion_reminder = []
|
result = self.find_next_same_color_all_directions_recursion(state, x, y, path_option,
|
||||||
recursion_reminder.append([x, y])
|
recursion_reminder, True)
|
||||||
result = self.find_next_same_color_all_directions_recursion(state, x, y, path_option, recursion_reminder, True)
|
|
||||||
if result == STATUS_FOUND_ENDING:
|
if result == STATUS_FOUND_ENDING:
|
||||||
path_option.append([x, y])
|
path_option.append([x, y])
|
||||||
if len(path_option) >= 5:
|
if len(path_option) >= 5:
|
||||||
full_moves.append((state[x, y], path_option))
|
full_moves.append((state[x, y], path_option))
|
||||||
if self.data_score_map[x, y] >= 1:
|
if self.data_score_map[x, y] >= 1:
|
||||||
path_option = []
|
path_option = [[x, y]]
|
||||||
path_option.append([x, y])
|
|
||||||
recursion_reminder = []
|
|
||||||
recursion_reminder.append([x, y])
|
|
||||||
self.find_next_same_color_all_directions_recursion2(state, x, y, path_option)
|
self.find_next_same_color_all_directions_recursion2(state, x, y, path_option)
|
||||||
if len(path_option) >= 3:
|
if len(path_option) >= 3:
|
||||||
reserve_moves.append((state[x, y], path_option))
|
reserve_moves.append((state[x, y], path_option))
|
||||||
@@ -370,7 +347,6 @@ class Field:
|
|||||||
self.execute_move(res_dic[key])
|
self.execute_move(res_dic[key])
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
def convert_moves_to_dic_by_color(self, reserve_moves):
|
def convert_moves_to_dic_by_color(self, reserve_moves):
|
||||||
dic = {}
|
dic = {}
|
||||||
for color, move in reserve_moves:
|
for color, move in reserve_moves:
|
||||||
@@ -381,7 +357,6 @@ class Field:
|
|||||||
dic[color] = move
|
dic[color] = move
|
||||||
return dic
|
return dic
|
||||||
|
|
||||||
|
|
||||||
def print_move(self, move):
|
def print_move(self, move):
|
||||||
mp = []
|
mp = []
|
||||||
for point in move:
|
for point in move:
|
||||||
@@ -436,19 +411,14 @@ class Field:
|
|||||||
upper_right_x = current_x - 1
|
upper_right_x = current_x - 1
|
||||||
upper_right_y = current_y + 1
|
upper_right_y = current_y + 1
|
||||||
|
|
||||||
directions = []
|
directions = [[left_x, left_y], [lower_left_x, lower_left_y], [lower_x, lower_y],
|
||||||
directions.append([left_x, left_y])
|
[lower_right_x, lower_right_y], [right_x, right_y], [upper_right_x, upper_right_y],
|
||||||
directions.append([lower_left_x, lower_left_y])
|
[upper_x, upper_y], [upper_left_x, upper_left_y]]
|
||||||
directions.append([lower_x, lower_y])
|
|
||||||
directions.append([lower_right_x, lower_right_y])
|
|
||||||
directions.append([right_x, right_y])
|
|
||||||
directions.append([upper_right_x, upper_right_y])
|
|
||||||
directions.append([upper_x, upper_y])
|
|
||||||
directions.append([upper_left_x, upper_left_y])
|
|
||||||
|
|
||||||
return directions
|
return directions
|
||||||
|
|
||||||
def find_next_same_color_all_directions_recursion(self, state, current_x, current_y, path_store, recursion_reminder, look_for_ending):
|
def find_next_same_color_all_directions_recursion(self, state, current_x, current_y, path_store, recursion_reminder,
|
||||||
|
look_for_ending):
|
||||||
directions = self.get_directions_array(current_x, current_y)
|
directions = self.get_directions_array(current_x, current_y)
|
||||||
color = state[current_x, current_y]
|
color = state[current_x, current_y]
|
||||||
|
|
||||||
@@ -456,7 +426,9 @@ class Field:
|
|||||||
if self.is_direction_in_bounce_and_same_color(state, direction, color) == 1:
|
if self.is_direction_in_bounce_and_same_color(state, direction, color) == 1:
|
||||||
if (self.data_score_map[direction[0], direction[1]] >= 2) and (direction not in recursion_reminder):
|
if (self.data_score_map[direction[0], direction[1]] >= 2) and (direction not in recursion_reminder):
|
||||||
recursion_reminder.append(direction)
|
recursion_reminder.append(direction)
|
||||||
result = self.find_next_same_color_all_directions_recursion(state, direction[0], direction[1], path_store , recursion_reminder, look_for_ending)
|
result = self.find_next_same_color_all_directions_recursion(state, direction[0], direction[1],
|
||||||
|
path_store, recursion_reminder,
|
||||||
|
look_for_ending)
|
||||||
if result == STATUS_FOUND_CONTINUATION:
|
if result == STATUS_FOUND_CONTINUATION:
|
||||||
path_store.append(direction)
|
path_store.append(direction)
|
||||||
return STATUS_FOUND_CONTINUATION
|
return STATUS_FOUND_CONTINUATION
|
||||||
@@ -486,48 +458,16 @@ class Field:
|
|||||||
if self.is_direction_in_bounce_and_same_color(state, direction, color) == 1:
|
if self.is_direction_in_bounce_and_same_color(state, direction, color) == 1:
|
||||||
if (self.data_score_map[direction[0], direction[1]] >= 1) and (direction not in path_store):
|
if (self.data_score_map[direction[0], direction[1]] >= 1) and (direction not in path_store):
|
||||||
path_store.append(direction)
|
path_store.append(direction)
|
||||||
result = self.find_next_same_color_all_directions_recursion2(state, direction[0], direction[1], path_store)
|
result = self.find_next_same_color_all_directions_recursion2(state, direction[0], direction[1],
|
||||||
|
path_store)
|
||||||
|
|
||||||
if result == STATUS_FOUND_DEADEND:
|
if result == STATUS_FOUND_DEADEND:
|
||||||
return STATUS_FOUND_DEADEND
|
return STATUS_FOUND_DEADEND
|
||||||
|
|
||||||
return STATUS_FOUND_DEADEND
|
return STATUS_FOUND_DEADEND
|
||||||
|
|
||||||
|
|
||||||
def score_for_attached_same_color_all_directions(self, state, current_x, current_y):
|
def score_for_attached_same_color_all_directions(self, state, current_x, current_y):
|
||||||
left_x = current_x - 1
|
directions = self.get_directions_array(current_x, current_y)
|
||||||
left_y = current_y
|
|
||||||
|
|
||||||
right_x = current_x + 1
|
|
||||||
right_y = current_y
|
|
||||||
|
|
||||||
upper_x = current_x
|
|
||||||
upper_y = current_y - 1
|
|
||||||
|
|
||||||
lower_x = current_x
|
|
||||||
lower_y = current_y + 1
|
|
||||||
|
|
||||||
lower_left_x = current_x + 1
|
|
||||||
lower_left_y = current_y - 1
|
|
||||||
|
|
||||||
lower_right_x = current_x + 1
|
|
||||||
lower_right_y = current_y + 1
|
|
||||||
|
|
||||||
upper_left_x = current_x - 1
|
|
||||||
upper_left_y = current_y - 1
|
|
||||||
|
|
||||||
upper_right_x = current_x - 1
|
|
||||||
upper_right_y = current_y + 1
|
|
||||||
|
|
||||||
directions = []
|
|
||||||
directions.append([left_x, left_y])
|
|
||||||
directions.append([right_x, right_y])
|
|
||||||
directions.append([lower_x, lower_y])
|
|
||||||
directions.append([upper_x, upper_y])
|
|
||||||
directions.append([lower_left_x, lower_left_y])
|
|
||||||
directions.append([lower_right_x, lower_right_y])
|
|
||||||
directions.append([upper_left_x, upper_left_y])
|
|
||||||
directions.append([upper_right_x, upper_right_y])
|
|
||||||
|
|
||||||
score = 0
|
score = 0
|
||||||
color = state[current_x, current_y]
|
color = state[current_x, current_y]
|
||||||
|
|||||||
BIN
crop/bigbomb.jpg
BIN
crop/bigbomb.jpg
Binary file not shown.
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 4.4 KiB |
BIN
crop/hsh_base_bigbomb.jpg
Normal file
BIN
crop/hsh_base_bigbomb.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 986 KiB |
BIN
crop/reset_screen.jpg
Normal file
BIN
crop/reset_screen.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 761 KiB |
Reference in New Issue
Block a user