#!/usr/bin/env python

import sys

class Grid(object):

    def __init__(self):
        self.board = [[None] * 10 for i in range(22)]
        self.score = 0
        self.lines_clear = 0

    def draw_board(self):

        current_board = self.board
        
        for row in current_board:
            row = map(lambda cell: '.' if cell == None else cell, row)
            print ' '.join(row)

    def given(self):
        
        for index, row in enumerate(self.board):
            self.board[index] = [None if cell == '.' else cell 
                                 for cell in raw_input() if cell != ' ']

    def clear(self):
        self.board = [[None] * 10 for i in range(22)]

    def show_score(self):
        print self.score

    def show_clear_lines(self):
        print self.lines_clear

    def step(self):
        for index, row in enumerate(self.board):
            if all(row) and row[0] != None:
                self.board[index] = [None] * 10
                self.score += 100
                self.lines_clear += 1



def main():
    
    grid = Grid()

    commands = {'p' : grid.draw_board, 
                'g' : grid.given, 
                'c' : grid.clear,
                '?s': grid.show_score,
                '?n': grid.show_clear_lines,
                's' : grid.step}

    while True:
        command =  raw_input()
        if command == 'q':
            break
        commands[command]()
        


if __name__ == '__main__':
    main()
@@ -1038,44 +1038,812 @@
 %0A%0A%0A%0A
-def main(
+class Tetramino(object):%0A%0A    def __init__(self, shape=None):%0A%0A        self.shape = shape%0A%0A    def print_tet(self):%0A%0A        for row in self.shape:%0A            row = map(lambda cell: '.' if cell == None else cell, row)%0A            print ' '.join(row)%0A%0A%0A%0Aclass I_tet(Tetramino
 ):%0A
+%0A
     
-%0A    grid = Grid()%0A%0A
+def __init__(self):%0A%0A        self.shape = %5B%5BNone, None, None, None%5D,%0A                      %5B'c', 'c', 'c', 'c'%5D,%0A                      %5BNone, None, None, None%5D,%0A                      %5BNone, None, None, None%5D%5D%0A%0A%0A%0Aclass Operator(object):%0A%0A    def __init__(self):%0A%0A        self.grid = Grid()%0A        self.active_tet = Tetramino()%0A%0A    def set_active_set(self, block):%0A%0A        i_tet = I_tet()%0A        %0A        shapes = %7B'I': i_tet%7D%0A%0A        return shapes%5Bblock%5D%0A%0A%0A    def receive_signal(self):%0A%0A        while True:%0A%0A        
     
@@ -1856,24 +1856,29 @@
 ds = %7B'p' : 
+game.
 grid.draw_bo
@@ -1903,14 +1903,27 @@
     
+  
+      
 'g' : 
+game.
 grid
@@ -1951,14 +1951,27 @@
     
+      
+  
 'c' : 
+game.
 grid
@@ -1998,14 +1998,27 @@
     
+ 
+       
 '?s': 
+game.
 grid
@@ -2050,14 +2050,27 @@
     
+        
 '?n': 
+game.
 grid
@@ -2108,14 +2108,27 @@
     
+        
 's' : 
+game.
 grid
@@ -2136,27 +2136,72 @@
 step
-%7D%0A
+,
 %0A    
-while True:%0A
+                    't' : game.active_tet.print_tet%7D%0A%0A    
     
@@ -2226,24 +2226,32 @@
 _input()%0A   
+%0A       
      if comm
@@ -2278,22 +2278,28 @@
     
+ 
+   
 break%0A
+%0A 
         
 comm
@@ -2298,26 +2298,94 @@
     
+   if 
 command
-s%5B
+.isupper():%0A                self.active_tet = self.set_active_set(
 command
-%5D(
 )%0A  
@@ -2394,44 +2394,132 @@
     
+ 
-%0A%0A%0Aif __name__ == '__main__':%0A    main
+   else:%0A                commands%5Bcommand%5D()%0A%0A%0A%0Aif __name__ == '__main__':%0A    %0A    game = Operator()%0A    game.receive_signal
 ()

Create Tetramino class Create Operator class Test 8 passed