Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
tic
N=10; % size of Isle
Qisles=100; % Qty of Isles to process to find error rate
rng(15,'twister'); % creation fixed set of Isles
valid=0;
while valid<Qisles
q=floor(N/4)+randi(floor(N*N/4));
idx=randperm(N*N);
mb=zeros(N);
mb(idx(1:q))=1;
for i=1:10 % Pre-Evolve
%mb0=mb;
mc=conv2(single(mb),[1 1 1;1 0 1;1 1 1],'same');
mb=~(mc<2 | mc>3) & ((mb & mc==2) | (mb & mc==3) | (~mb & mc==3));
end
if nnz(mb)>N*N/10 % Avoid empty isles
% figure(1);imagesc(mb0)
% figure(2);imagesc(mb)
valid=valid+1;
Isle{valid}=mb;
end
end % while to create cases
errTot=0;
for i=1:Qisles
isle_predict=predict_prior_isle(Isle{i});
m1=isle_predict; % Evolve to calculate errors
mc=conv2(single(m1),[1 1 1;1 0 1;1 1 1],'same');
isle_created=~(mc<2 | mc>3) & ((m1 & mc==2) | (m1 & mc==3) | (~m1 & mc==3));
err=N*N-nnz(Isle{i}==isle_created);
errTot=errTot+err;
end % Qisles
toc
assignin('caller','score',min(200,floor(1000*errTot/N/N/Qisles)));
Elapsed time is 0.033561 seconds.
|
Omit columns averages from a matrix
527 Solvers
110 Solvers
123 Solvers
07 - Common functions and indexing 1
338 Solvers
Find the next Fibonacci number
223 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!