Code covered by the BSD License
-
armyantsimulator(contestAntFH...
MATLAB 2008 Army Ants Contest
-
getComplexity(filename)
GETCOMPLEXITY Calculate the maximum complexity in an M-file.
-
grade(main,foodStart,red,blac...
Copyright 2008 The MathWorks, Inc.
-
house_solver(mainMap,foodMap,...
Copyright 2008 The MathWorks, Inc.
-
runcontest(drawboard,doBoards)
RUNCONTEST Test an entry.
-
solver(mainMap,foodMap,myAntM...
Copyright 2008 The MathWorks, Inc.
-
View all files
from
MATLAB Contest - Army Ants
by The MATLAB Contest Team
All the files needed to develop and score an entry for the MATLABĀ® Programming Contest.
|
| runcontest(drawboard,doBoards) |
function [message,results,timeElapsed] = runcontest(drawboard,doBoards)
%RUNCONTEST Test an entry.
% [MESSAGE,RESULTS,TIME] = RUNCONTEST(DRAWBOARD) runs the M-file
% solver.m against all the problems defined in testsuite_sample.mat. The
% input DRAWBOARD specifies if you want to graphically visualize the results.
% MESSAGE returns a summary of the testing. RESULTS measures how well the
% entry solved the problem, and TIME measures the time the entry took to
% compute its answer.
%
% [MESSAGE,RESULTS,TIME] = RUNCONTEST(DRAWBOARD, DOBOARDS) runs the M-file
% solver.m against the problems enumerated in the vector DOBOARDS
% as defined in testsuite_sample.mat. DRAWBOARD is handles as above.
% Copyright 2008 The MathWorks, Inc.
% Argument parsing.
if (nargin < 1)
drawboard = 0;
end
load testsuite_sample testsuite
if (nargin < 2)
doBoards = 1:numel(testsuite);
end
n = numel(testsuite);
responses = cell(n,1);
% Run the submission for each problem in the suite.
time0 = cputime;
for i = doBoards
responses{i} = armyantsimulator(@solver,@house_solver,testsuite(i),drawboard);
end
% get the elapsed time
timeElapsed = cputime-time0;
if drawboard
% time is not accurate when drawing the board
timeElapsed = NaN;
end
scores = zeros(n,1);
for k = doBoards
inputs = struct2cell(testsuite(k));
scores(k) = grade(inputs{:},responses{k});
end
% Report results.
results = sum(scores);
message = sprintf('results: %.2f\ntime: %.2f',results,timeElapsed);
|
|
Contact us at files@mathworks.com