gistlib
main.mfunction minesweeper_board(row, col, num_mines) board = zeros(row, col); % Randomly place mines mine_spots = randperm(row * col, num_mines); for i = 1:num_mines r = floor((mine_spots(i)-1) / col) + 1; c = mod(mine_spots(i)-1, col) + 1; board(r, c) = -1; % -1 represents a mine end disp(board); end 371 chars16 lines
function minesweeper_board(row, col, num_mines) board = zeros(row, col); % Randomly place mines mine_spots = randperm(row * col, num_mines); for i = 1:num_mines r = floor((mine_spots(i)-1) / col) + 1; c = mod(mine_spots(i)-1, col) + 1; board(r, c) = -1; % -1 represents a mine end disp(board); end
gistlibby LogSnag