Skip to content
Snippets Groups Projects
Commit cf20c98e authored by Taddeüs Kroes's avatar Taddeüs Kroes
Browse files

Make detectable board higher

parent 5fba1b44
No related branches found
No related tags found
No related merge requests found
......@@ -6,12 +6,13 @@ COLUMNS = 7
BLOCK_SIZE = 60
MAX_COLUMN_HEIGHT = 546
DETECT_COLUMN_OFFSET_X = 8, 50
DETECT_COLUMN_OFFSET_Y = -11
DETECT_COLUMN_OFFSET_X = 9, 49
DETECT_COLUMN_OFFSET_Y = 11
MIN_COLUMN_SAT = 130
MIN_COLUMN_VAL = 120
COLUMN_VSHIFT = [-2, -2, -1, -1, 0, 0, 0]
COLUMN_VSHIFT = [1, 1, 1, 0, 0, 0, 0]
#COLUMN_VSHIFT = [2, 2, 1, 1, 0, 0, 0]
RED, PINK, GREEN, BLUE, YELLOW, NOBLOCK = range(6)
BOMB_OFFSET = NOBLOCK + 1
......@@ -58,14 +59,14 @@ def detect_columns(board):
h, s, v = board.getpixel((x, y))
return s > MIN_COLUMN_SAT and v > MIN_COLUMN_VAL
a, b = DETECT_COLUMN_OFFSET_X
miny = -min(DETECT_BASIC_Y, DETECT_BOMB_Y)
for y in range(MAX_COLUMN_HEIGHT, BLOCK_SIZE, -1):
for y in range(MAX_COLUMN_HEIGHT, miny + BLOCK_SIZE, -1):
for col in range(COLUMNS):
x = col * BLOCK_SIZE
if saturated(x + a, y) and saturated(x + b, y):
if all(saturated(x + cx, y) for cx in DETECT_COLUMN_OFFSET_X):
#print('found bottom in column', col)
return y + 1 - DETECT_COLUMN_OFFSET_Y + COLUMN_VSHIFT[col]
return y + 1 + DETECT_COLUMN_OFFSET_Y - COLUMN_VSHIFT[col]
def detect_block_type(board, x, y):
......@@ -92,7 +93,8 @@ def detect_block_type(board, x, y):
def detect_blocks(board):
maxy = detect_columns(board) - BLOCK_SIZE
for y in range(maxy, 0, -BLOCK_SIZE):
miny = -min(DETECT_BASIC_Y, DETECT_BOMB_Y)
for y in range(maxy, miny, -BLOCK_SIZE):
for col in range(COLUMNS):
x = col * BLOCK_SIZE
yield detect_block_type(board, x, y + COLUMN_VSHIFT[col])
......@@ -127,7 +129,8 @@ def print_board(blocks, exa, held):
if exa is not None:
print(' ' * exa + ' |')
print(' ', '-' * (exa - 1), '(', 'rpgby RPGBY'[held], ')',
print(' ' * int(exa > 0), '-' * (exa - 1),
'(', 'rpgby RPGBY'[held], ')',
'-' * (COLUMNS - exa - 2), sep='')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment