SRL Archive - Other Scripts

Coin Flipper


smithsps

2008-03-29 21:58:33

Heres a script I just made for fun. :D

It just simulates flipping a a set amount of times.

program CoinFlipper;

const
TW = 100000; //Times to flip coin.

var
H, T, TD, TempWait : integer;

Procedure Report;
begin
ClearDebug;
writeln('{}---------- Coin Flipper ----------{}');
writeln(Padr('{}- Times Flipped: '+ IntToStr(TD), 36)+ '-{}');
writeln('{}-----------------------------------{}');
writeln(Padr('{}- Landed on Heads: '+ IntToStr(H), 36)+ '-{}');
writeln(Padr('{}- Landed on Tails: '+ IntToStr(T), 36)+ '-{}');
writeln('{}-----------------------------------{}');
end;

Procedure SemiReport;
begin
ClearDebug;
writeln('{}-------------- Coin Flipper --------------{}');
writeln(Padr('{}-- Times Flipped: '+ IntToStr(TD)+ ' out of '+ IntToStr(TW), 43)+ '--{}');
writeln('{}-------------------------------------------{}');
end;

Function CWait(Amount : integer): integer;
begin //Used to speed up script.
if (Amount <= 100000) then Result := 10;
if (Amount >= 100000) then Result := 100;
if (Amount >= 1000000) then Result := 1000;
end;

Procedure TWait;
begin
wait(1);
SemiReport;
TempWait := 0;
end;

Procedure HorT;
begin
if (TempWait = CWait(TW)) then TWait;
case Random(2) of
0: H := H + 1;
1: T := T + 1;
end;
TempWait := TempWait + 1;
TD := TD + 1;
end;


begin
ClearDebug;
while TW > TD do HorT;
Report;
end.

Dice Roller
program DiceRoller;

const
TimesToRoll = 185;//Times to roll Dice

var
TimesRolled, TempWait : integer;
One, Two, Thr, Fou, Fiv, Six : integer;

Procedure Report;
begin
ClearDebug;
writeln('{}----------- Dice Roller -----------{}');
writeln(Padr('{}- Times Rolled: '+ IntToStr(TimesRolled), 36)+ '-{}');
writeln('{}-----------------------------------{}');
writeln(Padr('{}- Landed on One: '+ IntToStr(One), 36)+ '-{}');
writeln(Padr('{}- Landed on Two: '+ IntToStr(Two), 36)+ '-{}');
writeln(Padr('{}- Landed on Three: '+ IntToStr(Thr), 36)+ '-{}');
writeln(Padr('{}- Landed on Four: '+ IntToStr(Fou), 36)+ '-{}');
writeln(Padr('{}- Landed on Five: '+ IntToStr(Fiv), 36)+ '-{}');
writeln(Padr('{}- Landed on Six: '+ IntToStr(Six), 36)+ '-{}');
writeln('{}-----------------------------------{}');
end;

Procedure SemiReport;
begin
ClearDebug;
writeln('{}--------------- Dice Roller ---------------{}');
writeln(Padr('{}-- Times Flipped: '+ IntToStr(TimesRolled)+ ' out of '+ IntToStr(TimesToRoll), 43)+ '--{}');
writeln('{}-------------------------------------------{}');
end;

Function CWait(Amount : integer): integer;
begin //Used to speed up script.
if (TimesToRoll <= 100000) then Result := 10;
if (TimesToRoll >= 100000) then Result := 100;
if (TimesToRoll >= 1000000) then Result := 1000;
end;

Procedure TWait;
begin
wait(1);
SemiReport;
TempWait := 0;
end;

Procedure Roll;
begin
if (TempWait = CWait(TimesToRoll)) then TWait;
case Random(6) of
0: One := One + 1;
1: Two := Two + 1;
2: Thr := Thr + 1;
3: Fou := Fou + 1;
4: Fiv := Fiv + 1;
5: Six := Six + 1;
end;
TimesRolled := TimesRolled + 1;
TempWait := TempWait + 1;
end;

begin
ClearDebug;
while (TimesToRoll > TimesRolled) do Roll;
Report;
end.

Card Picker
program CardGiver;

const
HowManyCards = 2;//How many cards you want

var
CardsPicked : integer;

Procedure PickCard;
begin
case Random(52) of
0: writeln('Ace of Spades');
1: writeln('Two of Spades');
2: writeln('Three of Spades');
3: writeln('Four of Spades');
4: writeln('Five of Spades');
5: writeln('Six of Spades');
6: writeln('Seven of Spades');
7: writeln('Eight of Spades');
8: writeln('Nine of Spades');
9: writeln('Ten of Spades');
10: writeln('Jack of Spades');
11: writeln('Queen of Spades');
12: writeln('King of Spades');
13: writeln('Ace of Clubs');
14: writeln('Two of Clubs');
15: writeln('Three of Clubs');
16: writeln('Four of Clubs');
17: writeln('Five of Clubs');
18: writeln('Six of Clubs');
19: writeln('Seven of Clubs');
20: writeln('Eight of Clubs');
21: writeln('Nine of Clubs');
22: writeln('Ten of Clubs');
23: writeln('Jack of Clubs');
24: writeln('Queen of Clubs');
25: writeln('King of Clubs');
26: writeln('Ace of Hearts');
27: writeln('Two of Hearts');
28: writeln('Three of Hearts');
29: writeln('Four of Hearts');
30: writeln('Five of Hearts');
31: writeln('Six of Hearts');
32: writeln('Seven of Hearts');
33: writeln('Eight of Hearts');
34: writeln('Nine of Hearts');
35: writeln('Ten of Hearts');
36: writeln('Jack of Hearts');
37: writeln('Queen of Hearts');
38: writeln('King of Hearts');
39: writeln('Ace of Diamonds');
40: writeln('Two of Diamonds');
41: writeln('Three of Diamonds');
42: writeln('Four of Diamonds');
43: writeln('Five of Diamonds');
44: writeln('Six of Diamonds');
45: writeln('Seven of Diamonds');
46: writeln('Eight of Diamonds');
47: writeln('Nine of Diamonds');
48: writeln('Ten of Diamonds');
49: writeln('Jack of Diamonds');
50: writeln('Queen of Diamonds');
51: writeln('King of Diamonds');
end;
CardsPicked := CardsPicked + 1;
end;

begin
ClearDebug;
while (HowManyCards > CardsPicked) do PickCard;
end.

supermoose

2008-03-29 22:03:12

haha you have good fantasy xD

smithsps

2008-03-29 22:08:47

No Im just a fan of him :D
Im not gay, im not a girl

Edit: I like the movies

Lacky

2008-03-30 05:19:30

From: supermoose
haha you have good fantasy xD


What are you talking about?

From: smithsps
No Im just a fan of him :D
Im not gay, im not a girl

Edit: I like the movies


I don't understand? Who are you talking about? :confused: lol

Regarding the script, it's sweet. ^_^ Random Heads/Tails, HERE I COME!

smithsps

2008-03-30 10:16:12

I used to have a '007' (James Bond) in my sig.
Thanks for liking my script.

Edit:
Updated Script with real time progress.

Edit2:
Added Dice Roller

Edit3:
Added Card Picker

drizzt

2008-03-30 13:26:14

they all look pretty sweet, except, card picker has two aces of hearts and no ace of diamonds

smithsps

2008-03-30 13:53:39

Oh woops… Changing THx

Lacky

2008-03-31 02:52:55

Sweet. Testing the new ones now.

Wow! Great! :p

palmpilot71

2008-04-03 13:48:21

Hehe I'm running it till the highest number Windows can calculate:1,316,134,911
I'll tell results later!

mixster

2008-04-03 13:50:16

It'll crash/go crazy at around flip 2147483647. How do know? Maximum 32Int (aka Integer) can hold (2^32 - 1) ;)

EvilChicken!

2008-04-03 13:51:47

Guys, this is an old thread.
But anyway, if you change it to "LongInt" it won't crash as early?

mixster

2008-04-03 13:55:33

It's from earlier this week…
And it wouldn't crash as early, though you mean Int64 of course as there is no LongInt in Scar (I think, I'm sure I tried it, but it was either the same as Integer or wasn't the same as an Int64…).