function [ result, roll, point ] = craps_game ( bet )

%*****************************************************************************80
%
%% craps_game() simulates one game of craps.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    18 July 2022
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer bet: the amount of money that the player has bet.
%
%  Output:
%
%    integer result: the amount the player has won or lost.
%
%    integer roll: the number of times the dice were rolled.
%
%    integer point: the sum of the dice on the first roll.
%
% rng ( 'shuffle' );

  roll = 0;

  while ( true )

    roll = roll + 1;
    dice = randi ( [ 1, 6 ], 2, 1 );
    value = sum ( dice );

    if ( roll == 1 )

      point = value;

      if ( value == 7 || value == 11 )
        result = + bet;
        return
      elseif ( value == 2 || value == 3 || value == 12 )
        result = - bet;
        return
      end

    else

      if ( value == point )
        result = + bet;
        return
      elseif ( value == 7 )
        result = - bet;
        return
      end

    end

    roll = roll + 1;

  end

  return
end

