Probability of something appearing[need help] - Programmers Heaven

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

#### Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# Probability of something appearing[need help]

Posts: 7Member
Hi, im programming a fruit machine as part of an IT course. So far i have gone through making it pretty easily, but have got to, i cant work out how to change how probable it is of a fruits appearing, like cherries more likely to appear than bells. I also need help with having the ability to hold. below is the code of my program(prepare for scrolling).
-----------------------------------------------------------------------
program fruitmachine;

uses crt;

var bet,semibank,spin,bank,winings,yahoo,endscreen,endscreenwin,mulitplier,holdyn,checker,check,check1,written,blob,hold5050,rand:integer;
var fruit : array[1..9] of string;

begin
repeat
cursoroff;
//Initialising fruits
fruit[1]:=' cherry ';
fruit[2]:=' banana ';
fruit[3]:=' lemon ';
fruit[4]:=' orange ';
fruit[5]:=' bar ';
fruit[6]:=' melon ';
fruit[7]:=' coconut ';
fruit[8]:=' bell ';
fruit[9]:=' butter ';

//writing of reels:
gotoxy(25,10);
write(char(201));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(203));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(203));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(187));

gotoxy(25,11);
write(char(186));
gotoxy(36,11);
write(char(186));
gotoxy(47,11);
write(char(186));
gotoxy(58,11);
write(char(186));

gotoxy(25,12);
write(char(186));
gotoxy(36,12);
write(char(186));
gotoxy(47,12);
write(char(186));
gotoxy(58,12);
write(char(186));

gotoxy(25,13);
write(char(186));
gotoxy(36,13);
write(char(186));
gotoxy(47,13);
write(char(186));
gotoxy(58,13);
write(char(186));

gotoxy(25,14);
write(char(186));
gotoxy(36,14);
write(char(186));
gotoxy(47,14);
write(char(186));
gotoxy(58,14);
write(char(186));

gotoxy(25,15);
write(char(186));
gotoxy(36,15);
write(char(186));
gotoxy(47,15);
write(char(186));
gotoxy(58,15);
write(char(186));

gotoxy(25,16);
write(char(186));
gotoxy(36,16);
write(char(186));
gotoxy(47,16);
write(char(186));
gotoxy(58,16);
write(char(186));

gotoxy(25,17);
write(char(186));
gotoxy(36,17);
write(char(186));
gotoxy(47,17);
write(char(186));
gotoxy(58,17);
write(char(186));

gotoxy(25,18);
write(char(186));
gotoxy(36,18);
write(char(186));
gotoxy(47,18);
write(char(186));
gotoxy(58,18);
write(char(186));

gotoxy(25,19);
write(char(186));
gotoxy(36,19);
write(char(186));
gotoxy(47,19);
write(char(186));
gotoxy(58,19);
write(char(186));

gotoxy(25,20);
write(char(200));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(202));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(202));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(188));
//end of writing blank reels
//instructions:
gotoxy(60,10);
write('INSTRUCTIONS:');
gotoxy(60,11);
write('-type 4 to quit');
gotoxy(60,12);
write('-type 01 to to bank');
gotoxy(60,13);
gotoxy(60,14);
write('to hold...');
gotoxy(60,15);
write('YOU MUST BET OVER 5!');

repeat
gotoxy(30,4);
write('place a bet');
cursoron;
gotoxy(30,5);
write(' ');
gotoxy(30,5);

cursoroff;
//to BANK:
if bet = 01 then
begin
winings:=semibank;
end;
until (bet > 5) or (bet = 4);
//resetting the spin:
spin:=0;

//if bet is 4 it skips to end scene(0 is the quit function)
//at first i tried to do it with an IF statement, but it disabled
//the ability to play the game. i then, whilst writing these notes, the
//repeat-until did the job just fine.
//'spinning' animation:
if bet > 5 then
begin
repeat

//randomizer
//left reel
randomize;
rand:=random(8);
rand:=rand+1;
gotoxy(26,15);
if rand = 1 then
begin
checker:=1;
write(fruit[1]);
end;
if rand = 2 then
begin
checker:=2;
write(fruit[2]);
end;
if rand = 3 then
begin
checker:=3;
write(fruit[3]);
end;
if rand = 4 then
begin
checker:=4;
write(fruit[4]);
end;
if rand = 5 then
begin
checker:=5;
write(fruit[5]);
end;
if rand = 6 then
begin
checker:=6;
write(fruit[6]);
end;
if rand = 7 then
begin
checker:=7;
write(fruit[7]);
end;
if rand = 8 then
begin
checker:=8;
write(fruit[8]);
end;
if rand = 9 then
begin
checker:=9;
write(fruit[9]);
end;
//center reel
rand:=random(8);
rand:=rand+1;
gotoxy(37,15);
if rand = 1 then
begin
check:=1;
write(fruit[1]);
end;
if rand = 2 then
begin
check:=2;
write(fruit[2]);
end;
if rand = 3 then
begin
check:=3;
write(fruit[3]);
end;
if rand = 4 then
begin
check:=4;
write(fruit[4]);
end;
if rand = 5 then
begin
check:=5;
write(fruit[5]);
end;
if rand = 6 then
begin
check:=6;
write(fruit[6]);
end;
if rand = 7 then
begin
check:=7;
write(fruit[7]);
end;
if rand = 8 then
begin
check:=8;
write(fruit[8]);
end;
if rand = 9 then
begin
check:=9;
write(fruit[9]);
end;
//right reel
rand:=random(8);
rand:=rand+1;
gotoxy(48,15);
if rand = 1 then
begin
check1:=1;
write(fruit[1]);
end;
if rand = 2 then
begin
check1:=2;
write(fruit[2]);
end;
if rand = 3 then
begin
check1:=3;
write(fruit[3]);
end;
if rand = 4 then
begin
check1:=4;
write(fruit[4]);
end;
if rand = 5 then
begin
check1:=5;
write(fruit[5]);
end;
if rand = 6 then
begin
check1:=6;
write(fruit[6]);
end;
if rand = 7 then
begin
check1:=7;
write(fruit[7]);
end;
if rand = 8 then
begin
check1:=8;
write(fruit[8]);
end;
if rand = 9 then
begin
check1:=9;
write(fruit[9]);
end;
delay(100);
spin:=spin+1;
until spin = 25;

end;

//randomizer for HOLDING
randomize;
hold5050:=random(1)+1;

//randomizer
//left reel
randomize;
rand:=random(8);
rand:=rand+1;
gotoxy(26,15);
if rand = 1 then
begin
checker:=1;
write(fruit[1]);
end;
if rand = 2 then
begin
checker:=2;
write(fruit[2]);
end;
if rand = 3 then
begin
checker:=3;
write(fruit[3]);
end;
if rand = 4 then
begin
checker:=4;
write(fruit[4]);
end;
if rand = 5 then
begin
checker:=5;
write(fruit[5]);
end;
if rand = 6 then
begin
checker:=6;
write(fruit[6]);
end;
if rand = 7 then
begin
checker:=7;
write(fruit[7]);
end;
if rand = 8 then
begin
checker:=8;
write(fruit[8]);
end;
if rand = 9 then
begin
checker:=9;
write(fruit[9]);
end;
//center reel
rand:=random(8);
rand:=rand+1;
gotoxy(37,15);
if rand = 1 then
begin
check:=1;
write(fruit[1]);
end;
if rand = 2 then
begin
check:=2;
write(fruit[2]);
end;
if rand = 3 then
begin
check:=3;
write(fruit[3]);
end;
if rand = 4 then
begin
check:=4;
write(fruit[4]);
end;
if rand = 5 then
begin
check:=5;
write(fruit[5]);
end;
if rand = 6 then
begin
check:=6;
write(fruit[6]);
end;
if rand = 7 then
begin
check:=7;
write(fruit[7]);
end;
if rand = 8 then
begin
check:=8;
write(fruit[8]);
end;
if rand = 9 then
begin
check:=9;
write(fruit[9]);
end;
//right reel
rand:=random(8);
rand:=rand+1;
gotoxy(48,15);
if rand = 1 then
begin
check1:=1;
write(fruit[1]);
end;
if rand = 2 then
begin
check1:=2;
write(fruit[2]);
end;
if rand = 3 then
begin
check1:=3;
write(fruit[3]);
end;
if rand = 4 then
begin
check1:=4;
write(fruit[4]);
end;
if rand = 5 then
begin
check1:=5;
write(fruit[5]);
end;
if rand = 6 then
begin
check1:=6;
write(fruit[6]);
end;
if rand = 7 then
begin
check1:=7;
write(fruit[7]);
end;
if rand = 8 then
begin
check1:=8;
write(fruit[8]);
end;
if rand = 9 then
begin
check1:=9;
write(fruit[9]);
end;

gotoxy(26,15);
//For 3 the same
if checker = check and check1 then
begin
if checker = 1 then
begin
mulitplier:=3;
end;
if checker = 2 then
begin
mulitplier:=4;
end;
if checker = 3 then
begin
mulitplier:=5;
end;
if checker = 4 then
begin
mulitplier:=6;
end;
if checker = 5 then
begin
mulitplier:=7;
end;
if checker = 6 then
begin
mulitplier:=8;
end;
if checker = 7 then
begin
mulitplier:=9;
end;
if checker = 8 then
begin
mulitplier:=10;
end;
if checker = 9 then
begin
mulitplier:=20;
end;
bet:=bet*mulitplier;

end;
//For rell 1 and 2 the same
if checker = check then
begin
if checker = 1 then
begin
mulitplier:=2;
end;
if checker = 2 then
begin
mulitplier:=3;
end;
if checker = 3 then
begin
mulitplier:=4;
end;
if checker = 4 then
begin
mulitplier:=5;
end;
if checker = 5 then
begin
mulitplier:=6;
end;
if checker = 6 then
begin
mulitplier:=7;
end;
if checker = 7 then
begin
mulitplier:=8;
end;
if checker = 8 then
begin
mulitplier:=9;
end;
if checker = 9 then
begin
mulitplier:=10;
end;
bet:=bet*mulitplier;

end;
//For reel 1 and 3 the same
if checker = check1 then
begin
if checker = 1 then
begin
mulitplier:=2;
end;
if checker = 2 then
begin
mulitplier:=3;
end;
if checker = 3 then
begin
mulitplier:=4;
end;
if checker = 4 then
begin
mulitplier:=5;
end;
if checker = 5 then
begin
mulitplier:=6;
end;
if checker = 6 then
begin
mulitplier:=7;
end;
if checker = 7 then
begin
mulitplier:=8;
end;
if checker = 8 then
begin
mulitplier:=9;
end;
if checker = 9 then
begin
mulitplier:=10;
end;
bet:=bet*mulitplier;

end;
//For reel 2 and 3 the same
if check = check1 then
begin
if check = 1 then
begin
mulitplier:=2;
end;
if check = 2 then
begin
mulitplier:=3;
end;
if check = 3 then
begin
mulitplier:=4;
end;
if check = 4 then
begin
mulitplier:=5;
end;
if check = 5 then
begin
mulitplier:=6;
end;
if check = 6 then
begin
mulitplier:=7;
end;
if check = 7 then
begin
mulitplier:=8;
end;
if check = 8 then
begin
mulitplier:=9;
end;
if check = 9 then
begin
mulitplier:=10;
end;
if mulitplier > 1 then
begin
bet:=bet*mulitplier;

end else
begin
bet:=0;
end;

end;

semibank:=semibank+bet;
gotoxy(2,10);
cursoron;
write('you have ',bet,' pounds!');
gotoxy(2,11);
write('you have ',winings,' secured');

until bet = 4;
gotoxy(2,15);
if bet > 0 then
begin
if bank = 0 then
begin
winings:=bet;
end;
write('you won ',winings,'pounds!');
gotoxy(2,16);

end;
clrscr;
repeat
if winings > 0 then
begin
if winings > 500 then
begin
repeat
gotoxy(37,12);
write('YOU WON ',winings,' POUNDS');
endscreenwin:=endscreenwin+1;
until endscreenwin = 100;
end;
end;
gotoxy(35,12);
write('G');
delay(100);
write('A');
delay(100);
write('M');
delay(100);
write('E');
delay(100);
write(' ');
delay(100);
write('O');
delay(100);
write('V');
delay(100);
write('E');
delay(100);
write('R');
delay(1000);
gotoxy(35,12);

write(' ');
delay(01);
if winings > 500 then
begin

repeat

gotoxy(2,2);
write(' YAhoo YAhoo Yahoo YAhooo YAhooo');
gotoxy(2,4);
write(' YAhoo YAhoo Yahoo YAhooo YAhooo');
gotoxy(2,6);
write(' YAhoo YAhoo Yahoo YAhooo YAhooo');
gotoxy(2,8);
write(' YAhoo YAhoo Yahoo YAhooo YAhooo');
gotoxy(2,10);
write(' YAhoo YAhoo Yahoo YAhooo YAhooo');
gotoxy(2,14);
write(' YAhoo YAhoo Yahoo YAhooo YAhooo');
gotoxy(2,16);
write(' YAhoo YAhoo Yahoo YAhooo YAhooo');
gotoxy(2,18);
write(' YAhoo YAhoo Yahoo YAhooo YAhooo');
gotoxy(2,20);
write(' YAhoo YAhoo Yahoo YAhooo YAhooo');
gotoxy(2,22);
write(' YAhoo YAhoo Yahoo YAhooo YAhooo');
delay(100);
gotoxy(2,2);
write(' ');
gotoxy(2,4);
write(' ');
gotoxy(2,6);
write(' ');
gotoxy(2,8);
write(' ');
gotoxy(2,10);
write(' ');
gotoxy(2,14);
write(' ');
gotoxy(2,16);
write(' ');
gotoxy(2,18);
write(' ');
gotoxy(2,20);
write(' ');
gotoxy(2,22);
write(' ');
yahoo:=yahoo+1;
delay(100);
until yahoo = 100;
end;
endscreen:=endscreen+1;
until endscreen = 1000;
gotoxy(23,5);
write('press enter to quit');