예제 #1
0
 def gen_rotation(self):
     """Generate a rotated shape for the block."""
     new_shape = []
     for index in reverse_range(len(self.shape[0])):
         new_column = []
         for column in self.shape:
             new_column.append(column[index])
         new_shape.append(new_column)
     return new_shape
예제 #2
0
    def remove_full_lines(self):
        """Remove each full line from the heap."""
        lines_to_remove = set()
        for index in xrange(len(self.remnants[0])):
            if self.line_full(index):
                lines_to_remove.add(index)

        yellow_blocks = 0
        col_index = len(self.remnants[0]) - 1
        for index in reverse_range(len(self.remnants[0])):
            if not index in lines_to_remove:
                for column in self.remnants:
                    column[col_index] = column[index]
                col_index -= 1
            else: # Lines with yellow blocks count double
                for column in self.remnants:
                    if column[index] == 4:
                        yellow_blocks += 1
                        break
        self.removed += len(lines_to_remove) + yellow_blocks