Skip to content

Commit

Permalink
fix piece colors
Browse files Browse the repository at this point in the history
  • Loading branch information
mikhail-vlasenko committed Jan 6, 2022
1 parent fbfc626 commit 4e9a7bf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
16 changes: 8 additions & 8 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ def name_piece(piece: int) -> str:
return PIECE_NAMES[piece]


# in BGR
# in RGB
original_colors = np.zeros((7, 3), np.int)
original_colors[0] = (230, 228, 180)
original_colors[1] = (182, 228, 247)
original_colors[2] = (177, 99, 140)
original_colors[3] = (228, 177, 148)
original_colors[4] = (128, 180, 235)
original_colors[5] = (180, 161, 235)
original_colors[6] = (171, 240, 177)
original_colors[0] = (180, 228, 230)
original_colors[1] = (247, 228, 182)
original_colors[2] = (140, 99, 177)
original_colors[3] = (148, 177, 228)
original_colors[4] = (235, 180, 128)
original_colors[5] = (235, 161, 180)
original_colors[6] = (177, 240, 171)

# tetr.io colors in RGB
tetrio_colors = np.zeros((7, 3), np.int)
Expand Down
1 change: 1 addition & 0 deletions src/scan_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def get_figure_by_color(screen: np.array):
for j in range(len(screen[0])):
pixel = screen[i, j][:3]
for piece_idx in range(len(piece_colors)):
# piece_colors has [::-1] to convert from RGB to BGR because pixel is in BGR
distance = cmp_pixel(piece_colors[piece_idx][::-1], pixel)
if distance < 10:
return piece_idx
Expand Down

0 comments on commit 4e9a7bf

Please sign in to comment.