示例#1
0
    def test_scan_King(self):
        new_score = score.Score()
        king = pieces.King(True, 2, 14)
        moves = [{'from_row': 2, 'from_col': 14, 'to_row': 1, 'to_col': 14, 'score': 43.0},
                {'from_row': 2, 'from_col': 14, 'to_row': 1, 'to_col': 15, 'score': 5},
                {'from_row': 2, 'from_col': 14, 'to_row': 2, 'to_col': 15, 'score': 5},
                {'from_row': 2, 'from_col': 14, 'to_row': 3, 'to_col': 15, 'score': 5},
                {'from_row': 2, 'from_col': 14, 'to_row': 3, 'to_col': 14, 'score': 5},
                {'from_row': 2, 'from_col': 14, 'to_row': 3, 'to_col': 13, 'score': 5},
                {'from_row': 2, 'from_col': 14, 'to_row': 1, 'to_col': 13, 'score': 5}]
        
        up          = scans.scan_up(self.actual_board, king)
        up_right    = scans.scan_up_right(self.actual_board, king)
        right       = scans.scan_right(self.actual_board, king)
        down_right  = scans.scan_down_right(self.actual_board, king)
        down        = scans.scan_down(self.actual_board, king)
        down_left   = scans.scan_down_left(self.actual_board, king)
        left        = scans.scan_left(self.actual_board, king)
        up_left     = scans.scan_up_left(self.actual_board, king)
        L           = scans.scan_L(self.actual_board, king)

        player.scan(new_score, up, king, True)
        player.scan(new_score, up_right, king, True)
        player.scan(new_score, right, king, True)
        player.scan(new_score, down_right, king, True)
        player.scan(new_score, down, king, True)
        player.scan(new_score, down_left, king, True)
        player.scan(new_score, left, king, True)
        player.scan(new_score, up_left, king, True)
        player.scan(new_score, L, king, True)

        self.assertEqual(moves, new_score.play_moves)
示例#2
0
    def test_scan_Pawn(self):
        new_score = score.Score()
        pawn = pieces.Pawn(True, 2, 13)
        moves = [{'from_row': 2, 'from_col': 13, 'to_row': 1, 'to_col': 13, 'score': 60.15},
                {'from_row': 2, 'from_col': 13, 'to_row': 1, 'to_col': 14, 'score': 43.0}]
        
        up          = scans.scan_up(self.actual_board, pawn)
        up_right    = scans.scan_up_right(self.actual_board, pawn)
        right       = scans.scan_right(self.actual_board, pawn)
        down_right  = scans.scan_down_right(self.actual_board, pawn)
        down        = scans.scan_down(self.actual_board, pawn)
        down_left   = scans.scan_down_left(self.actual_board, pawn)
        left        = scans.scan_left(self.actual_board, pawn)
        up_left     = scans.scan_up_left(self.actual_board, pawn)
        L           = scans.scan_L(self.actual_board, pawn)

        player.scan(new_score, up, pawn, True)
        player.scan(new_score, up_right, pawn, True)
        player.scan(new_score, right, pawn, True)
        player.scan(new_score, down_right, pawn, True)
        player.scan(new_score, down, pawn, True)
        player.scan(new_score, down_left, pawn, True)
        player.scan(new_score, left, pawn, True)
        player.scan(new_score, up_left, pawn, True)
        player.scan(new_score, L, pawn, True)

        self.assertEqual(moves, new_score.play_moves)
示例#3
0
    def test_scan_bishop(self):
        new_score = score.Score()
        bishop = pieces.Bishop(False, 1, 14)
        moves = [{'from_row': 1, 'from_col': 14, 'to_row': 0, 'to_col': 15, 'score': -8},
                {'from_row': 1, 'from_col': 14, 'to_row': 2, 'to_col': 15, 'score': -8},
                {'from_row': 1, 'from_col': 14, 'to_row': 2, 'to_col': 13, 'score': -97},
                {'from_row': 1, 'from_col': 14, 'to_row': 0, 'to_col': 13, 'score': -8}]
        
        up          = scans.scan_up(self.actual_board, bishop)
        up_right    = scans.scan_up_right(self.actual_board, bishop)
        right       = scans.scan_right(self.actual_board, bishop)
        down_right  = scans.scan_down_right(self.actual_board, bishop)
        down        = scans.scan_down(self.actual_board, bishop)
        down_left   = scans.scan_down_left(self.actual_board, bishop)
        left        = scans.scan_left(self.actual_board, bishop)
        up_left     = scans.scan_up_left(self.actual_board, bishop)
        L           = scans.scan_L(self.actual_board, bishop)

        player.scan(new_score, up, bishop, True)
        player.scan(new_score, up_right, bishop, True)
        player.scan(new_score, right, bishop, True)
        player.scan(new_score, down_right, bishop, True)
        player.scan(new_score, down, bishop, True)
        player.scan(new_score, down_left, bishop, True)
        player.scan(new_score, left, bishop, True)
        player.scan(new_score, up_left, bishop, True)
        player.scan(new_score, L, bishop, True)

        self.assertEqual(moves, new_score.play_moves)
示例#4
0
def scan_posible_moves(actual_board, color):
    new_score = score.Score()

    for i in range(16):
        for j in range(16):
            piece = actual_board.matrix_pieces[i][j]
            if not isinstance(piece, pieces.EmptySquare):
                up          = scans.scan_up(actual_board, piece)
                up_right    = scans.scan_up_right(actual_board, piece)
                right       = scans.scan_right(actual_board, piece)
                down_right  = scans.scan_down_right(actual_board, piece)
                down        = scans.scan_down(actual_board, piece)
                down_left   = scans.scan_down_left(actual_board, piece)
                left        = scans.scan_left(actual_board, piece)
                up_left     = scans.scan_up_left(actual_board, piece)
                L           = scans.scan_L(actual_board, piece)

                scan(new_score, up, piece, color)
                scan(new_score, up_right, piece, color)
                scan(new_score, right, piece, color)
                scan(new_score, down_right, piece, color)
                scan(new_score, down, piece, color)
                scan(new_score, down_left, piece, color)
                scan(new_score, left, piece, color)
                scan(new_score, up_left, piece, color)
                scan(new_score, L, piece, color)

    return new_score
示例#5
0
    def test_scan_up(self):
        queen = pieces.Queen(False, 8, 8)
        pawn = pieces.Pawn(True, 5, 8)

        self.board_game.matrix_pieces[8][8] = queen
        self.board_game.matrix_pieces[5][8] = pawn

        up = scans.scan_up(self.board_game, queen)

        self.assertIsInstance(next(up), pieces.EmptySquare)
        self.assertIsInstance(next(up), pieces.EmptySquare)
        self.assertIsInstance(next(up), pieces.Pawn)