Professional Documents
Culture Documents
{
################################# Student Info ################################
#######
Name: Sridhar Vineeth Goud Edulakanti
UIN: 674663737
CSC 540C, Assignment HW3
###############################################################################
########
}
{
############################# Program Details ##################################
#########
NAME OF THE PROGRAM : Roulette
DESCRIPTION : In this game, players may choose to place bets on either a single
number or a range of numbers, the colors red or black, or whether
the number is odd or even.
A Roulette Wheel that contains numbers ranging from 0 to 36 is
spinned and a ball
is then dropped onto the wheel. The ball lands on a number and
numbers play Major Role in the game. Here, in this code, this numb
er
is generated randomly using a code snipped of the Random Number
Generator and the number of spins to be performed are to be entere
d
by the user.
The Problem Statement(as quoted in the Problem Definition) require
s
the following Calculations to be performed:
1. How often could a number be generated up to two times in a row on
an average and also that how often could the number be generated
up to three times in a row.
2. When a particular number is chosen at random, determine how many
times would it be generated twice in a row ? (Suppose a random num
ber
be 13, etc)
3. The longest run of Evens and Odds in a row in one program simulati
on
needs to be determined.
################################################################################
###########
}
uses crt; {#### This Program uses the crt Library ####}
{
######################## Details of the Declared Variables ####################
##########
num_wheel:=37;
s on the wheel #}
count_twice:=0;
count_thrice:=0;
gap_twice:=0;
gap_thrice:=0;
temp_gap:=0;
temp_gap:=0;
end else begin
temp_gap:=temp_gap+1;
{# If two Consecutive Numbers yielded are
NOT the Same, Increment the Gap Counter #}
end;
end;
temp_gap:=0; {# Re-initializing the Gap Counter to 0 (Zero) #}
for i:=0 to num_spins do begin
{# Begin to Loop through all the Spins #
}
if((rand_array[i]=rand_array[i+1]) and (rand_array[i]=rand_array[i+2])) then
begin
{# Verifying if three Consecutive Spins
Produce Equal Numbers #}
count_thrice:=count_thrice+1;
{# If three Consecutive Numbers are Same
, then Increment the Counter #}
gap_thrice:=gap_thrice+temp_gap+1; {# Tracking the Number of Spins betwee
n the three Consecutive Occurences of any Number #}
temp_gap:=0;
end else begin
temp_gap:=temp_gap+1;
{# If three Consecutive Numbers are NOT
the same ones, Increment the Gap Counter #}
end;
end;
if(count_twice>0) then begin
avg_twice:=(gap_twice/count_twice);
writeln();
writeln('The same numbers are repeated twice in a row for every ',avg_twice:
1:2,' numbers on an average.');
{# Output 1: Average Frequency of occure
nces of a Number - TWICE in a row #}
end else begin
writeln();
writeln('No number repeats Twice in a row');
end;
if(count_thrice>0) then begin
avg_thrice:=(gap_thrice/count_thrice);
writeln();
writeln('The same numbers are repeated Thrice in a row for every ',avg_thric
e:1:2,' numbers on an average.');
{# Output 2: Average Frequency of occure
nces of a Number - THRICE in a row #}
end else begin
writeln();
writeln('No number repeats Thrice in a row');
end;
writeln();
writeln('Please choose any number of your choice between 1-36');
readln(num);
{# Seeking the Input from the User for t
he Choice of the Number between 1-36 #}
temp_gap:=0;
for i:=0 to num_spins do begin
if(rand_array[i]=num) then begin
odd_max:=0;
#}
odd_count:=0;
}