function grid = life_init ( prob, m, n )

%*****************************************************************************80
%
%% life_init() initializes the life grid.
%
%  Discussion:
%
%    We assume the MxN grid is surrounded by a boundary layer of 0 cells.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    18 July 2021
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real PROB, the probability that a grid cell should be alive.
%
%    integer M, N, the number of rows and columns
%    of interior grid cells.
%
%  Output:
%
%    integer GRID(1+M+1,1+N+1), the initial grid.
%
  grid = zeros ( 1 + m + 1, 1 + n + 1 );

  for j = 1 : n
    for i = 1 : m
      r = rand ( 1, 1 );
      if ( r <= prob )
        grid(i+1,j+1) = 1;
      end
    end
  end

  return
end
