From c3e677ca0acf29809212f6ad3bcac21925133d5f Mon Sep 17 00:00:00 2001 From: Thaloria Date: Sat, 29 Jul 2023 21:30:00 +0200 Subject: [PATCH] update litris with board detection --- field.py | 5 +++++ litris.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/field.py b/field.py index 7182537..374fda5 100644 --- a/field.py +++ b/field.py @@ -151,6 +151,11 @@ class Field(): + def check_crucial_pos_to_be_free(self): + if self.field.state[19][9] == ' ' and self.field.state[19][10] == ' ' and self.field.state[18][9] == ' ' and self.field.state[18][10] == ' ': + return True + return False + def predict_gaps_in_next_rotation(self): tmp_state = copy(self.state) tmp_state = self.rotate_90_degree_anticlckwise(tmp_state) diff --git a/litris.py b/litris.py index 3a8da36..6ab3da3 100644 --- a/litris.py +++ b/litris.py @@ -70,7 +70,7 @@ class Litris(GameBase): self.move_stone(column - offset_col, rotation) self.drop_down() print(self.field) - if self.field.get_line_count() >= 6 and self.field.height() <= 1 and self.field.state[19][9] == ' ': + if self.field.get_line_count() >= 6 and self.field.height() <= 2 and self.field.check_crucial_pos_to_be_free(): if self.field.predict_gaps_in_next_rotation() <= 3: self.update_move_mode()