this is for holding javascript data
Code
DLA.m
%% Preallocations
size = 500;
numSeeds = 1;
map = setup(size, numSeeds, 3);
p = 0.4;
seedCounter = 0;
SC = 1;
steps = 0;
r_max = 0;
%% Simulation
frameskip = 10000;
r = randi(size, 1, 2); % Set a particle somewhere randomly in the lattice
while seedCounter/size^2 < p
steps = steps + 1;
randIndex = randi(2);
r(randIndex) = r(randIndex) + sign(rand() - 0.5); % randomly choose a near point to move to
if r(1) > size || r(2) > size || r(1) < 1 || r(2) < 1 % if it is outside the lattice
r = randi(size, 1, 2);
elseif isNear(r, map) == 1 && rand() < SC % if it is near a seed, in probability SC
temp = norm(r);
if temp > r_max
r_max = temp;
end
map(r(1), r(2)) = 1;
r = randi(size, 1, 2);
seedCounter = seedCounter + 1;
end
if mod(steps, frameskip) == 0 % Every 10000 frames
temp = map(r(1), r(2)); % keep the value of wherever the walker is
map(r(1), r(2)) = 2; % change it to 2, so we can color it different
disp(seedCounter/size^2);
disp(steps);
imagesc(map); % draw the lattice
drawnow; % forces the script to draw before the loop ends
map(r(1), r(2)) = temp; % set the map back to the previous value
end
end
%% Graphics
disp(log(seedCounter)/log(r_max));
imagesc(map);