Exemplo n.º 1
0
 def test_blocked_moves(self):
     position = [
         [(TOWER, WHITE), (TOWER, WHITE), None, None, None, None, None, None],
         [None, None, None, None, None, None, None, None],
         [(TOWER, WHITE), None, None, None, None, None, None, None],
         [None, None, None, None, None, None, None, None],
         [None, None, None, None, None, None, None, None],
         [None, None, None, None, None, None, None, None],
         [None, None, None, None, None, None, None, None],
         [None, None, None, None, None, None, None, None]]
     chess_position = ChessPosition(position, 3)
     moves = chess_position._get_tower_moves(position[0][0], 0, 0)
     self.assertEquals(len(moves), 1, moves)
     move = moves[0]
     self.assertExistsPiece(move, (TOWER, WHITE), 1, 0)
     position = [
         [(TOWER, WHITE), (TOWER, WHITE), None, None, None, None, None, None],
         [None, None, None, None, None, None, None, None],
         [(TOWER, BLACK), None, None, None, None, None, None, None],
         [None, None, None, None, None, None, None, None],
         [None, None, None, None, None, None, None, None],
         [None, None, None, None, None, None, None, None],
         [None, None, None, None, None, None, None, None],
         [None, None, None, None, None, None, None, None]]
     chess_position = ChessPosition(position, 3)
     moves = chess_position._get_tower_moves(position[0][0], 0, 0)
     self.assertEquals(len(moves), 2, moves)
     move = moves[0]
     self.assertExistsPiece(move, (TOWER, WHITE), 1, 0)
     move = moves[1]
     self.assertExistsPiece(move, (TOWER, WHITE), 2, 0)
Exemplo n.º 2
0
 def test_blocked_moves(self):
     position = [[(TOWER, WHITE), (TOWER, WHITE), None, None, None, None,
                  None, None],
                 [None, None, None, None, None, None, None, None],
                 [(TOWER, WHITE), None, None, None, None, None, None, None],
                 [None, None, None, None, None, None, None, None],
                 [None, None, None, None, None, None, None, None],
                 [None, None, None, None, None, None, None, None],
                 [None, None, None, None, None, None, None, None],
                 [None, None, None, None, None, None, None, None]]
     chess_position = ChessPosition(position, 3)
     moves = chess_position._get_tower_moves(position[0][0], 0, 0)
     self.assertEquals(len(moves), 1, moves)
     move = moves[0]
     self.assertExistsPiece(move, (TOWER, WHITE), 1, 0)
     position = [[(TOWER, WHITE), (TOWER, WHITE), None, None, None, None,
                  None, None],
                 [None, None, None, None, None, None, None, None],
                 [(TOWER, BLACK), None, None, None, None, None, None, None],
                 [None, None, None, None, None, None, None, None],
                 [None, None, None, None, None, None, None, None],
                 [None, None, None, None, None, None, None, None],
                 [None, None, None, None, None, None, None, None],
                 [None, None, None, None, None, None, None, None]]
     chess_position = ChessPosition(position, 3)
     moves = chess_position._get_tower_moves(position[0][0], 0, 0)
     self.assertEquals(len(moves), 2, moves)
     move = moves[0]
     self.assertExistsPiece(move, (TOWER, WHITE), 1, 0)
     move = moves[1]
     self.assertExistsPiece(move, (TOWER, WHITE), 2, 0)
Exemplo n.º 3
0
    def test_all_side_moves(self):
        position = [
            [None, None, None, None, None, None, None, None],
            [None, None, (TOWER, BLACK), None, None, None, None, None],
            [None, (TOWER, BLACK), (TOWER, WHITE), (TOWER, BLACK), None, None, None, None],
            [None, None, (TOWER, BLACK), None, None, None, None, None],
            [None, None, None, None, None, None, None, None],
            [None, None, None, None, None, None, None, None],
            [None, None, None, None, None, None, None, None],
            [None, None, None, None, None, None, None, None]]
        chess_position = ChessPosition(position, 3)

        moves = chess_position._get_tower_moves(position[2][2], 2, 2)
        self.assertEquals(len(moves), 4, moves)
        move = moves[0]
        self.assertExistsPiece(move, (TOWER, WHITE), 3, 2)
        move = moves[1]
        self.assertExistsPiece(move, (TOWER, WHITE), 2, 3)
        move = moves[2]
        self.assertExistsPiece(move, (TOWER, WHITE), 1, 2)
        move = moves[3]
        self.assertExistsPiece(move, (TOWER, WHITE), 2, 1)
Exemplo n.º 4
0
    def test_all_side_moves(self):
        position = [[None, None, None, None, None, None, None, None],
                    [None, None, (TOWER, BLACK), None, None, None, None, None],
                    [
                        None, (TOWER, BLACK), (TOWER, WHITE), (TOWER, BLACK),
                        None, None, None, None
                    ],
                    [None, None, (TOWER, BLACK), None, None, None, None, None],
                    [None, None, None, None, None, None, None, None],
                    [None, None, None, None, None, None, None, None],
                    [None, None, None, None, None, None, None, None],
                    [None, None, None, None, None, None, None, None]]
        chess_position = ChessPosition(position, 3)

        moves = chess_position._get_tower_moves(position[2][2], 2, 2)
        self.assertEquals(len(moves), 4, moves)
        move = moves[0]
        self.assertExistsPiece(move, (TOWER, WHITE), 3, 2)
        move = moves[1]
        self.assertExistsPiece(move, (TOWER, WHITE), 2, 3)
        move = moves[2]
        self.assertExistsPiece(move, (TOWER, WHITE), 1, 2)
        move = moves[3]
        self.assertExistsPiece(move, (TOWER, WHITE), 2, 1)