added async stone detection thread

This commit is contained in:
2023-07-26 09:46:33 +02:00
parent 3c02d413a2
commit 7b63568fa5
2 changed files with 24 additions and 10 deletions

View File

@@ -1,4 +1,5 @@
#!/usr/bin/python
from copy import copy
from tetromino import Tetromino
@@ -59,7 +60,7 @@ class Field():
def rotate_state(self):
self.state = self.rotate_90_degree_anticlckwise(self.state)
#self.state = self.matrixflip(self.state, 'v')
print(self.state)
#print(self.state)
def get_line_count(self):
return self.cleared_rows
@@ -148,6 +149,18 @@ class Field():
self._line_clear()
return row
def predict_gaps_in_next_rotation(self):
tmp_state = copy(self.state)
tmp_state = self.rotate_90_degree_anticlckwise(tmp_state)
for row in range(int(self.HEIGHT/2)):
tmp_state[row] = [' ' for cols in range(Field.WIDTH)]
return sum(
["".join([row[col] for row in tmp_state]).lstrip().count(' ')
for col in range(Field.WIDTH)])
def count_gaps(self):
"""
Check each column one by one to make sure there are no gaps in the