function life_test ( )

%*****************************************************************************80
%
%% life_test() tests life().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 February 2019
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Martin Gardner,
%    Mathematical Games:
%    The Fantastic Combinations of John Conway's new solitaire game "Life",
%    Scientific American,
%    Volume 223, Number 4, October 1970, pages 120-123.
%
  addpath ( '../life' );

  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'life_test()\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  Test life().\n' );
  fprintf ( 1, '\n' );

  filename = 'life_000.txt';
  it_max = 10;
  m = 10;
  n = 10;
  prob = 0.20;

  grid = zeros ( m + 2, n + 2 );

  for it = 0 : it_max
    if ( it == 0 )
      grid = life_init ( prob, m, n );
    else
      grid = life_update ( m, n, grid );
    end
    life_display ( grid );
    pause ( 3 );
    life_write ( filename, m, n, grid )
    fprintf ( 1, '  %s\n', filename );
    filename = filename_inc ( filename );
  end
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'life_test():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

  rmpath ( '../life' );

  return
end
function timestamp ( )

%*****************************************************************************80
%
%% timestamp() prints the current YMDHMS date as a timestamp.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 February 2003
%
%  Author:
%
%    John Burkardt
%
  t = now;
  c = datevec ( t );
  s = datestr ( c, 0 );
  fprintf ( 1, '%s\n', s );

  return
end

