this is for holding javascript data
Leon Bello edited section_Simulation_and_Results__.tex
over 8 years ago
Commit id: 9d7f619f311b2477321875a5f02c08148c275852
deletions | additions
diff --git a/section_Simulation_and_Results__.tex b/section_Simulation_and_Results__.tex
index 630907f..60f2f6e 100644
--- a/section_Simulation_and_Results__.tex
+++ b/section_Simulation_and_Results__.tex
...
\section{Simulation and Results}
\verb|
%% Preallocations
size = 250;
numSeeds = 1;
map = setup(size, numSeeds);
p = 0.6;
seedCounter = 0;
steps = 3e7;
SC = 1;
%% Simulation
r = randi(size, 1, 2); % Start a particle somewhere randomly in the lattice
for i = 1:steps
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
map(r(1), r(2)) = 1;
r = randi(size, 1, 2);
disp('We got one!');
seedCounter = seedCounter + 1;
r_min = norm(r - round(size/2)*[1, 1]);
end
if seedCounter/size^2 > p
disp(seedCounter/size^2);
break;
end
disp(i/steps);
end
|