function [ grid, seed ] = life_init ( prob, m, n, seed )

%*****************************************************************************80
%
%% LIFE_INIT initializes the life grid.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    08 September 2013
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, real PROB, the probability that a grid cell
%    should be alive.
%
%    Input, integer M, N, the number of rows and columns
%    of interior grid cells.
%
%    Input/output, integer SEED, a seed for the random
%    number generator.
%
%    Output, integer GRID(1+M+1,1+N+1), the initial grid.
%
  for j = 0 : n + 1
    for i = 0 : m + 1
      grid(i+1,j+1) = 0;
    end
  end

  for j = 1 : n
    for i = 1 : m
      [ r, seed ] = r8_uniform_01 ( seed );
      if ( r <= prob )
        grid(i+1,j+1) = 1;
      end
    end
  end

  return
end
