function [ survived, statem ] = SingleSlitControl( u )

% initialise number of runs, noise, timestep
nrun = 10000;
sigma = 0.2;
dt = 0.1;

% score and survival matrices and stats
w = -ones(nrun,1);
dead = zeros(nrun,1);
survived = 0;

% matrix to record random steps
randomstore = zeros(nrun,length(0:dt:2));
lambda = 1;

% matrix to record population density
statem = zeros(length(0:dt:2), length(-10:10));

% loop over number of runs
for i=1:nrun
    x = 0; tref = 0;
    % loop through time
    for t=0:dt:2
        % record current position if still alive
        tref = round(t/dt+1);
        xref = round(x+10);
        if(dead(i) == 0)
            statem(tref,xref) = statem(tref,xref)+1;
        end
        % record and apply random perturbation
        r = normrnd(0,sigma);
        randomstore(i,floor(t/dt)+1) = r;
        % change from uncontrolled case: add control strategy
        x = x+r+u(tref);
        % implement the slit, kill the run if it didn't make it through
        if abs(t-1) < 2*dt
            if not(and(x > -2, x < -1))
                dead(i) = 1;
            end
        end
        if dead(i)==1
            t = 2;
        end
    end
    % if the run survived, record its final score
    if not(dead(i) == 1)
        survived = survived+1;
        w(i) = exp(-0.5*x*x/lambda)/nrun;
    end
end
