function casino_simulation_test ( )

%*****************************************************************************80
%
%% casino_simulation_test() tests casino_simulation().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    12 January 2023
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../casino_simulation' )

  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'casino_simulation_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s.\n', version ( ) );
  fprintf ( 1, '  Test casino_simulation().\n' );
%
%  Play one game, and print all the steps.

  stakes_initial = 5000.0;
  n = 100;
  verbose = true;
  [ stakes, w, l ] = casino_simulation ( stakes_initial, n, verbose );
%
%  Compute average winnings over many sets of 100 games.
%
  trial_num = 500;
  stakes_final = zeros ( trial_num, 1 );
  lose_num = 0;

  for i = 1 : trial_num
    stakes_initial = 5000.0;
    n = 100;
    verbose = false;
    [ stakes_final(i), w, l ] = casino_simulation ( stakes_initial, n, verbose );
    if ( stakes_final(i) < stakes_initial )
      lose_num = lose_num + 1;
    end
  end

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Number of trials was %d\n', trial_num );
  fprintf ( 1, '  Each trial involved tossing a coin %d times\n', n );
  fprintf ( 1, '  Initial stakes were %g\n', stakes_initial );
  fprintf ( 1, '  Number of trials with a final loss = %d\n', lose_num );
  fprintf ( 1, '  Minimum final stakes: %g\n', min ( stakes_final ) );
  fprintf ( 1, '  Average final stakes: %g\n', mean ( stakes_final ) );
  fprintf ( 1, '  Maximum final stakes: %g\n', max ( stakes_final ) );
  fprintf ( 1, '  Standard deviation:   %g\n', std ( stakes_final ) );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'casino_simulation_test():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

  rmpath ( '../casino_simulation' )

  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

