Skip to content

Commit 61019bd

Browse files
committed
refactor digit.py (now scan_field.py)
add new data (alex_notebook monitor size)
1 parent 83249ed commit 61019bd

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

AI_main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from direct_keys import *
44
import time
55
from figures import piece_weight, find_figure
6-
from digit import get_field
6+
from scan_field import get_field
77
import keyboard
88

99
FIELD_SIZE = [20, 10]

data.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ def get_next_3(self, img):
3434
next3 = n3xt[150:195]
3535
return next1, next2, next3
3636

37+
3738
misha = Consts(370, 970, 155, 455, 340, 540, 485, 560)
3839
alex = Consts(339, 895, 142, 422, 315, 505, 450, 475)
40+
alex_notebook = Consts(225, 888, 115, 441, 315, 505, 450, 475)
3941
maxx = Consts(370, 970, 155, 455, 340, 540, 485, 560)

main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import time
2-
from digit import get_field
2+
from scan_field import get_field
33
from figures import type_figure_ext
44
from AI_main import AI
55
import numpy as np

digit.py renamed to scan_field.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
from mss import mss
44
import data
55

6-
consts = data.alex # CUSTOM
7-
dbug = 0
6+
consts = data.alex_notebook # CUSTOM
7+
debug_status = 0
88

99
d = dict()
1010
d[0] = (230, 228, 180)
@@ -17,10 +17,10 @@
1717
d[7] = (96, 45, 36)
1818

1919

20-
def pD(arr, fsize=10):
21-
if dbug == 1:
20+
def print_image(arr, figure_size=10):
21+
if debug_status == 1:
2222
n = len(arr)
23-
fig = plt.figure(figsize=(fsize, fsize))
23+
fig = plt.figure(figsize=(figure_size, figure_size))
2424
for i in range(n):
2525
fig.add_subplot(1, n, i + 1)
2626
plt.imshow(arr[i])
@@ -52,13 +52,13 @@ def get_field():
5252

5353
next1, next2, next3 = map(get_figure, consts.get_next_3(img))
5454

55-
sizeCell = field.shape[0] // 20
55+
size_cell = field.shape[0] // 20
5656
arr = np.zeros((20, 10))
57-
for i in range(sizeCell):
57+
for i in range(size_cell):
5858
r1 = np.array(np.linspace(0, field.shape[0], 21)[:-1], int) + i
5959
r2 = np.array(np.linspace(0, field.shape[1], 11)[:-1], int) + i
6060
arr += field[r1][:, r2]
6161

62-
kek = np.array(arr / sizeCell + 0.5, int)
63-
pD((img, field, kek))
62+
kek = np.array(arr / size_cell + 0.5, int)
63+
print_image((img, field, kek))
6464
return kek, next1

0 commit comments

Comments
 (0)