update litris with board detection

This commit is contained in:
2023-07-29 20:12:51 +02:00
parent a9b76cde97
commit c9081bd371
2 changed files with 51 additions and 20 deletions

View File

@@ -15,18 +15,10 @@ class Litris(GameBase):
self.keyboard = Controller()
self.data_coordinates = np.zeros((20, 20), dtype=object)
self.observation = np.zeros((20, 20), dtype=int)
self.colors = [1, 2, 3, 4, 5, 6, 7, 8, 9]
self.offset_left = 610
self.offset_down = 40
self.fill_data_coordinates()
self.field = Field()
self.field_mem = Field()
self.litris_reset_board = cv.imread("control_elements/sodoku_reset_button.jpg", cv.IMREAD_COLOR)
@@ -34,17 +26,6 @@ class Litris(GameBase):
self.move_mode = 1
def fill_data_coordinates(self):
# 610 to 1950 = 1340 - 76 / 20 = 63
# 40 to 1380 = 1340 - 76 / 20 = 63
# spacing 19 * 4
dim = 63
e_spacing = 4
i_spacing = 4
for e in range(0, 20, 1):
for i in range(0, 20, 1):
self.data_coordinates[e][i] = [(i * dim) + (i * i_spacing), (e * dim) + (e * e_spacing), dim, dim]
def assess_playfield_and_make_move(self):
last_letter_received = time()
while True:
@@ -92,6 +73,7 @@ class Litris(GameBase):
if self.field.get_line_count() >= 6 and self.field.height() <= 2:
if self.field.predict_gaps_in_next_rotation() <= 5:
self.update_move_mode()
self.field = self.stone_id_thread.get_current_board_state()
self.field.rotate_state()
#self.update_move_mode()
self.field.reset_half_field()
@@ -105,6 +87,8 @@ class Litris(GameBase):
self.stone_id_thread.set_pick_up_status(False)
def drop_down(self):
if self.move_mode == 1:
down = Key.down