コード例 #1
0
    def testTouchToSolve(self):
        board.touch(self.b, (4,1))
        self.assertEqual(scoreboard(self.b), 30)

        b2 = board.newboard(
            """
            4 4 2 2 1
            0 0 2 3 4
            0 0 0 4 4
            3 0 0 3 4
            0 0 0 0 4
            3 0 0 0 3
            """)
        self.assertEquals(self.b, b2)

        board.touch(self.b, (1,4))

        b2 = board.newboard(
            """
            4 4 3 0 0
            0 0 3 0 0
            0 0 0 0 0
            4 0 0 0 0
            0 0 0 0 0
            4 0 0 0 0
            """)
        self.assertEquals(self.b, b2)

        board.touch(self.b, (0,1))

        b2 = board.newboard(
            """
            0 0 0 0 0
            0 0 4 0 0
            0 0 0 0 0
            0 0 0 0 0
            0 0 0 0 0
            0 0 0 0 0
            """)
        self.assertEquals(self.b, b2)

        board.touch(self.b, (1,2))
        
        b2 = board.newboard(
            """
            0 0 0 0 0
            0 0 0 0 0
            0 0 0 0 0
            0 0 0 0 0
            0 0 0 0 0
            0 0 0 0 0
            """)
        self.assertEquals(self.b, b2)
コード例 #2
0
    def testTouchToSolve(self):
        board.touch(self.b, (4, 1))
        self.assertEqual(scoreboard(self.b), 30)

        b2 = board.newboard("""
            4 4 2 2 1
            0 0 2 3 4
            0 0 0 4 4
            3 0 0 3 4
            0 0 0 0 4
            3 0 0 0 3
            """)
        self.assertEquals(self.b, b2)

        board.touch(self.b, (1, 4))

        b2 = board.newboard("""
            4 4 3 0 0
            0 0 3 0 0
            0 0 0 0 0
            4 0 0 0 0
            0 0 0 0 0
            4 0 0 0 0
            """)
        self.assertEquals(self.b, b2)

        board.touch(self.b, (0, 1))

        b2 = board.newboard("""
            0 0 0 0 0
            0 0 4 0 0
            0 0 0 0 0
            0 0 0 0 0
            0 0 0 0 0
            0 0 0 0 0
            """)
        self.assertEquals(self.b, b2)

        board.touch(self.b, (1, 2))

        b2 = board.newboard("""
            0 0 0 0 0
            0 0 0 0 0
            0 0 0 0 0
            0 0 0 0 0
            0 0 0 0 0
            0 0 0 0 0
            """)
        self.assertEquals(self.b, b2)
コード例 #3
0
 def testTouchOn01(self):
     board.touch(self.b, (0,1))
     b2 = board.newboard(
         """
         4 3 2 2 1
         0 4 1 3 4
         0 4 0 3 4
         2 0 0 1 4
         3 4 0 4 2
         1 1 0 4 1
         """)
     self.assertEquals(self.b, b2)
     
     board.touch(self.b, (0,1))
     b2 = board.newboard(
         """
         4 4 2 2 1
         0 4 1 3 4
         0 4 0 3 4
         2 0 0 1 4
         3 4 0 4 2
         1 1 0 4 1
         """)
     self.assertEquals(self.b, b2)
     
     board.touch(self.b, (0,1))
     b2 = board.newboard(
         """
         0 0 4 2 1
         0 0 2 3 4
         0 0 0 4 4
         4 0 0 3 4
         0 0 0 0 4
         2 3 0 0 2
         """)
     self.assertEquals(self.b, b2)
     
     board.touch(self.b, (2,3))
     b2 = board.newboard(
         """
         0 0 4 4 4
         0 0 3 0 0
         0 0 0 0 0
         0 0 0 0 0
         0 0 0 0 0
         3 3 0 0 4
         """)
     self.assertEquals(self.b, b2)
コード例 #4
0
 def setUp(self):
     self.b = board.newboard("""
         3 3 2 0 1
         2 1 2 3 3
         2 0 4 0 1
         4 1 3 4 2
         0 2 4 4 2
         2 2 4 2 2            
         """)
コード例 #5
0
    def testTouchOn01(self):
        board.touch(self.b, (0, 1))
        b2 = board.newboard("""
            4 3 2 2 1
            0 4 1 3 4
            0 4 0 3 4
            2 0 0 1 4
            3 4 0 4 2
            1 1 0 4 1
            """)
        self.assertEquals(self.b, b2)

        board.touch(self.b, (0, 1))
        b2 = board.newboard("""
            4 4 2 2 1
            0 4 1 3 4
            0 4 0 3 4
            2 0 0 1 4
            3 4 0 4 2
            1 1 0 4 1
            """)
        self.assertEquals(self.b, b2)

        board.touch(self.b, (0, 1))
        b2 = board.newboard("""
            0 0 4 2 1
            0 0 2 3 4
            0 0 0 4 4
            4 0 0 3 4
            0 0 0 0 4
            2 3 0 0 2
            """)
        self.assertEquals(self.b, b2)

        board.touch(self.b, (2, 3))
        b2 = board.newboard("""
            0 0 4 4 4
            0 0 3 0 0
            0 0 0 0 0
            0 0 0 0 0
            0 0 0 0 0
            3 3 0 0 4
            """)
        self.assertEquals(self.b, b2)
コード例 #6
0
 def setUp(self):
     self.b = board.newboard(
         """
         3 3 2 0 1
         2 1 2 3 3
         2 0 4 0 1
         4 1 3 4 2
         0 2 4 4 2
         2 2 4 2 2            
         """)
コード例 #7
0
 def testTouchOn00(self):
     board.touch(self.b, (0, 0))
     b2 = board.newboard("""
         0 3 2 2 1
         0 4 1 3 4
         0 4 0 3 4
         3 0 0 1 4
         3 4 0 4 2
         1 1 0 4 1
         """)
     self.assertEquals(self.b, b2)
コード例 #8
0
 def testTouchOn00(self):
     board.touch(self.b, (0,0))
     b2 = board.newboard(
         """
         0 3 2 2 1
         0 4 1 3 4
         0 4 0 3 4
         3 0 0 1 4
         3 4 0 4 2
         1 1 0 4 1
         """)
     self.assertEquals(self.b, b2)
コード例 #9
0
ファイル: game.py プロジェクト: 4Evergreen4/nsweeper
def game(stdscr, screen, screen_panel, field_h, field_w, mine_num):
    minefield = board.newboard(field_h, field_w, mine_num)
    minefield_list = minefield.getlist()
    display = draw(minefield, 1, 2)
    screen.clear()

    key = 0
    done = False
    while not(done):
        if key == ord('q'):
            return 'menu'
        display.cursormove(key)
        stdscr.refresh()
        screen.border()
        screen_panel.bottom()
        screen.refresh()
        display.drawboard()
        key = stdscr.getch()
コード例 #10
0
 def setUp(self):
     # game level.1.90
     self.b = board.newboard(game_1_90)
コード例 #11
0
 def setUp(self):
     # game level.1.90
     self.b = board.newboard(game_1_90)
コード例 #12
0
 def setUp(self):
     self.b = board.newboard(game_1_90_m4)