% mfile MoveFishLeft
% decide whether to move fish left, move, mark as having moved, and update boundaries
% decide whether fish can move left
  move( 2:d+1, 2:d+2 ) = fish( 2:d+1, 2:d+2 ) & ...
          ( fishdir( 2:d+1, 2:d+2 ) == 3 ) & ( ~shark( 2:d+1, 1:d+1 ) ) & ...
          ( ~fish( 2:d+1, 1:d+1 ) );
% decide whether fish can breed
  fbreed ( 2:d+1, 2:d+2 ) = ( fishage(  2:d+1, 2:d+2 ) > FBREED ) & ...
     move( 2:d+1, 2:d+2 );
% update fish positions
  fish( 2:d+1, 2:d+1 ) = ( fish( 2:d+1, 2:d+1 ) & (~move( 2:d+1, 2:d+1 ) ) )|...
          move( 2:d+1, 3:d+2 ) | fbreed( 2:d+1, 2:d+1 ) ;
% update fish ages
  fishage( 2:d+1, 2:d+1 ) = (fishage( 2:d+1, 2:d+1).*(~move( 2:d+1, 2:d+1 )) ...
                             .* fish( 2:d+1, 2:d+1 ) ) + ...
                             ( fishage( 2:d+1, 3:d+2 ) .* move( 2:d+1, 3:d+2 ));
  fishage( 2:d+1, 2:d+1 ) = fishage( 2:d+1, 2:d+1 ) .* (~shark( 2:d+1, 2:d+1 ));
% mark fish as having moved
  fishdir( 2:d+1, 2:d+1 ) =   fishdir( 2:d+1, 2:d+1 ) .* ...
                              ( ~move( 2:d+1, 1:d )) .* ...
                             (fishdir( 2:d+1, 2:d+1 ) ~= 3);
  UpdateBoundaries;
  if dbug == 1, 
      subplot(223), plotsharkfish;
      disp(['i= ',num2str(i),' just moved left']), keyboard, 
  end
