MATLAB debugging Othello program

I am trying to figure out why every move is considered invalid. The game is supposed ot run with two players playing a game of Othello.

function Othelloooooooo()
    load Othello.mat;
    imshow([Board{1,:};Board{2,:};Board{3,:};Board{4,:};Board{5,:};Board{6,:};Board{7,:};Board{8,:}])
    disp('Player 1 = White, Player 2  = Black');
    player = 1;
    game = 1;
    while game == 1
        %% Player's Turn
        if player == 1
            disp('Player 1 Turn');
            oppcolor = 'blackdisc';
            playercolor = 'whitedisc';
        else
            disp('Player 2 Turn');
            oppcolor = 'whitedisc';
            playercolor = 'blackdisc';
        end
        [row,column] = promptuserinput();
        [empty, adj] = checkValidMove(row,column,oppcolor,playercolor,Board);
        while empty == 0 || adj == 0
            [row, column] = promptuserinput();
            [empty, adj] = checkValidMove(row,column,playercolor,Board);
        end
        Board = makeMove(row, column, playercolor, oppcolor, Board);
        imshow([Board{1,:};Board{2,:};Board{3,:};Board{4,:};Board{5,:};Board{6,:};Board{7,:};Board{8,:}]);
        player = 3 - player; % Switch player
        % Check for end of game
        if ~anyValidMoves(Board, oppcolor)
            disp('No valid moves left. Game over.');
            break;
        end
        game = input('Please enter if you would like to continue the game (1 for yes, 2 for no): ');
        if game == 2
            break;
        end
    end %end for while loop
    % Display winner
    disp('Game over.');
    winner = getWinner(Board);
    if winner == 0
        disp('It is a draw!');
    elseif winner == 1
        disp('Player 1 (White) wins!');
    else
        disp('Player 2 (Black) wins!');
    end
end
function x = checkAdjacent(row, column, color, Board)
    directions = [-1, 0; 1, 0; 0, -1; 0, 1; -1, -1; -1, 1; 1, -1; 1, 1];
    x = 0; % Initialize to zero
    for d = 1:size(directions, 1)
        dir = directions(d, :);
        r = row + dir(1);
        c = column + dir(2);
        if r >= 1 && r <= 8 && c >= 1 && c <= 8 && strcmp(Board{r, c}, color)
            x = 1; % At least one adjacent square has the same color
            break; % No need to check further, so break the loop
        end
    end
end
function validMovesExist = anyValidMoves(Board, playercolor)
    validMovesExist = false;
    for row = 1:8
        for column = 1:8
            [empty, adj] = checkValidMove(row,column,playercolor,Board);
            if empty == 1 && adj == 1
                validMovesExist = true;
                return;
            end
        end
    end
end

function [empty, adj] = checkValidMove(row, column, oppcolor, playercolor, Board)
    % Check if the space is empty
    empty = isempty(Board{row,column});
    if empty == 1
        empty = 0;
        warning('Not an empty square move, try again');
        return;
    end
    
    % Check if adjacent squares have an opposite color
    adj = checkAdjacent(row, column, oppcolor, Board);
    if adj == 0
        warning('Not a valid move');
        return;
    end
    
    % Check if the move is valid and flip discs if needed
    BoardTemp = Board;
    BoardTemp{row, column} = playercolor;
    flipped = flipDiscs(row, column, oppcolor, playercolor, BoardTemp);
    if isempty(flipped)
        adj = 0;
        warning('Not a valid move');
        return;
    end
    
    empty = 1;
end

function flipped = flipDiscs(row, column, oppcolor, playercolor, Board)
    flipped = {};
    directions = [-1, 0; 1, 0; 0, -1; 0, 1; -1, -1; -1, 1; 1, -1; 1, 1];
    for d = 1:size(directions, 1)
        dir = directions(d, :);
        r = row + dir(1);
        c = column + dir(2);
        toFlip = {};
        while r >= 1 && r <= 8 && c >= 1 && c <= 8 && ~isempty(Board{r, c}) && strcmp(Board{r, c}, oppcolor)
            toFlip{end+1} = [r, c];
            r = r + dir(1);
            c = c + dir(2);
        end
        if r >= 1 && r <= 8 && c >= 1 && c <= 8 && ~isempty(Board{r, c}) && strcmp(Board{r, c}, playercolor)
            for i = 1:numel(toFlip)
                coord = toFlip{i};
                flipped{end+1} = coord;
                Board{coord(1), coord(2)} = playercolor;
            end
        end
    end
end

function Board = makeMove(row, column, playercolor, oppcolor, Board)
    Board{row, column} = playercolor;
    flipped = flipDiscs(row, column, oppcolor, playercolor, Board);
end

function [row,column] = promptuserinput()
    t = 1;
    while t == 1
        row = input('Please enter a row value:');
        column = input('Please enter a column value:');
        if row < 1 | row > 8 | column < 1 | column > 8
            t = 1;
            warning('Please enter a value between 1 and 8 (ex: 5).');
        else
            t = 2;
        end
    end
end

I have tried making sure that my function callings are correct and that they are in the right order. However, I have not figured it out yet. I think part of the issue lies in checking to see if the move is valid and the check adjacent function.

New contributor

Rachel Evers is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật