Skip to content

Commit 504f5a8

Browse files
committed
dogs drop update
1 parent eca43c2 commit 504f5a8

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

constants.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@
1616

1717
NEW_GAME_TRIGGER_POS = (210/402, 615/712)
1818
AVG_GAME_DURATION = 30 # seconds
19+
20+
21+
#Dogs drop
22+
DOGS_WHITE_COLOR_RANGE = (238, 256)

main.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
PIXELS_PER_ITERATION,
1717
NEW_GAME_TRIGGER_POS,
1818
AVG_GAME_DURATION,
19+
DOGS_WHITE_COLOR_RANGE,
1920
)
2021

2122

@@ -41,14 +42,25 @@ def check_running(frame, application_bbox) -> bool:
4142
return False
4243

4344

44-
def check_object(pixel:tuple[int]) -> bool:
45+
def check_object(frame, x:int, y:int) -> bool:
4546
""" Finding dropping objects by color """
46-
if COLOR_TRIGGERS['red']['min'] <= pixel[0] <= COLOR_TRIGGERS['red']['max']:
47-
if COLOR_TRIGGERS['green']['min'] <= pixel[1] <= COLOR_TRIGGERS['green']['max']:
48-
# print(pixel)
49-
if COLOR_TRIGGERS['blue']['min'] <= pixel[2] <= COLOR_TRIGGERS['blue']['max']:
47+
if COLOR_TRIGGERS['red']['min'] <= frame[y][x][0] <= COLOR_TRIGGERS['red']['max']:
48+
if COLOR_TRIGGERS['green']['min'] <= frame[y][x][1] <= COLOR_TRIGGERS['green']['max']:
49+
# print(frame[y][x])
50+
if COLOR_TRIGGERS['blue']['min'] <= frame[y][x][2] <= COLOR_TRIGGERS['blue']['max']:
5051
return True
5152

53+
#DOGS DROP
54+
if frame[y][x][0] == frame[y][x][1] == frame[y][x][2] and DOGS_WHITE_COLOR_RANGE[0] <= frame[y][x][0] <= DOGS_WHITE_COLOR_RANGE[1]:
55+
counter = 0
56+
for i in range(-1, 2):
57+
for j in range(-4, 2):
58+
counter += (frame[y + j][x + i][0] == frame[y + j][x + i][1] == frame[y + j][x + i][2] and DOGS_WHITE_COLOR_RANGE[0] <= frame[y + j][x + i][0] <= DOGS_WHITE_COLOR_RANGE[1])
59+
60+
if counter >= 10:
61+
return True
62+
63+
5264
return False
5365

5466

@@ -102,7 +114,7 @@ def main():
102114

103115
for x in x_range:
104116
for y in y_range:
105-
if check_object(frame[y][x]):
117+
if check_object(frame, x, y):
106118
mouse.move(x, y, absolute=True)
107119
mouse.click(button='left')
108120

0 commit comments

Comments
 (0)