% Simulate fish in "game of life"
% Inputs (call fish3init for sample set of input)
%   m = size of square, toroidally connected ocean
%   n = number of time steps to simulate
%   ofish(m,m) = initial distribution of fish  (1 for fish, 0 for no fish)
%
% Output
%   plot of fish ('o') at the end of every time step
%   (computation pauses after every plot; hit return to continue)
%
% Other routines used:
%   finit (optional)  - initializes inputs to some interesting values
%   initboundaries    - initialize boundaries before computation begins
%   updateboundaries  - update boundaries after every substep
%   plotfish          - plot output
%
% Main data structures:
%
%   fish(i,j) = 1 if fish present at (i,j), 0 otherwise
%
%   All these are of dimension d=m+2 by d, with an extra row and column
%   on all edges to accomodate toroidal connection
%
%   Initialize fish and shark data
       d=m+2;
       fish=[zeros(1,d);[zeros(m,1),ofish,zeros(m,1)];zeros(1,d)];
       initboundaries;
%
%   Set up graphics
       initplot;
       plotfish35; 
%
%   Loop over time steps
       for i=1:n,
           disp(['Computing time step i= ',num2str(i)])
%
%   Breed or die according to life rules
           lifearray;
%   Update boundaries according to toroidal connections
           updateboundaries;
%
%   Plot output
            plotfish35;
%           disp('Pause (hit return to continue)'), pause
            pause(.5);
        end