% mfile MoveFishUp 
% decide whether to move fish up, move, mark as having moved, and update 
% boundaries
% decide whether fish can move up
  move( 2:d+2, 2:d+1 ) = fish( 2:d+2, 2:d+1 ) & ...
          ( fishdir( 2:d+2, 2:d+1 ) == 2 ) & ( ~shark( 1:d+1, 2:d+1 ) ) & ...
          ( ~fish( 1:d+1, 2:d+1 ) );
% decide whether fish can breed
  fbreed ( 2:d+2, 2:d+1 ) = ( fishage(  2:d+2, 2:d+1 ) > FBREED ) & ...
         move( 2:d+2, 2:d+1 );
% 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( 3:d+2, 2:d+1 ) | 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( 3:d+2, 2:d+1 ) .* move( 3:d+2, 2:d+1 ));
  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( 3:d+2, 2:d+1 )) .* ...
                             (fishdir( 2:d+1, 2:d+1 ) ~= 2);
  UpdateBoundaries;
  if dbug == 1, 
      subplot(222), plotsharkfish;
      disp(['i= ',num2str(i),' just moved up']), keyboard, 
  end
