function temple_abm_mexican_wave
%TEMPLE_ABM_MEXICAN_WAVE
%   Model for a mexican wave in a sports stadium, generated by
%   spectators who stand up and sit down to create the wave as
%   an emergent structure. The provided model is very simple
%   and should be improved. Model: 0=sitting; 1=standing.
%   Update rule: if sitting and left neighbor standing, then
%   stand up; if standing, then sit down.
%
% 01/2016 by Benjamin Seibold
%            http://www.math.temple.edu/~seibold/

% Parameters
n = 40; % number of agents

% Initialization
x = double(1:n==round(n/3)); % a single agent is standing up

% Computation
for j = 1:80 % time loop
    % Plotting
    fprintf('%d',x)
    fprintf('\n')
    % Update rule
    x = ~x&x([end 1:end-1]); % If 0 & left neighbor 1, become 1; else: 0
    pause
end
