function output =SteppingStone( n,num_colors,duration )
%UNTITLED Summary of this function goes here
%   Detailed explanation goes here
initial_step=randi(num_colors,n,n);
figure(1); 
colormap(hsv(num_colors));

for i=1:duration
    random_ind=randi(n^2);
    adjacent_inds=zeros(1,8);
    
    adjacent_inds(1)=mod(random_ind-1,n.^2);
    adjacent_inds(2)=mod(random_ind-1+n,n.^2);
    adjacent_inds(3)=mod(random_ind+n,n.^2);
    adjacent_inds(4)=mod(random_ind+n+1,n.^2);
    adjacent_inds(5)=mod(random_ind+1,n.^2);
    adjacent_inds(6)=mod(random_ind-n+1,n.^2);
    adjacent_inds(7)=mod(random_ind-n,n.^2);    
    adjacent_inds(8)=mod(random_ind-n-1,n.^2);
    adjacent_inds(adjacent_inds==0)=n;
    pick_one=randi(8);
    random_neighbor_color=initial_step(adjacent_inds(pick_one));
    initial_step(random_ind)=random_neighbor_color;
    figure(1);
    image(initial_step);  
end

output=initial_step;

end

