mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2026-01-05 17:48:52 -08:00
Removed spaces from top-level directory names.
Spaces tend to cause annoyances in a Unix-style shell environment. This change fixes that.
This commit is contained in:
3
33_Dice/perl/README.md
Normal file
3
33_Dice/perl/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
|
||||
|
||||
Conversion to [Perl](https://www.perl.org/)
|
||||
42
33_Dice/perl/dice.pl
Executable file
42
33_Dice/perl/dice.pl
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/perl
|
||||
use strict;
|
||||
|
||||
|
||||
print ' 'x 34 . "DICE\n";
|
||||
print ' 'x 15 . "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY\n";
|
||||
print "\n\n\n";
|
||||
my @F;
|
||||
|
||||
#REM DANNY FREIDUS;
|
||||
print "THIS PROGRAM SIMULATES THE ROLLING OF A\n";
|
||||
print "PAIR OF DICE.\n";
|
||||
print "YOU ENTER THE NUMBER OF TIMES YOU WANT THE COMPUTER TO\n";
|
||||
print "'ROLL' THE DICE. WATCH OUT, VERY LARGE NUMBERS TAKE\n";
|
||||
print "A LONG TIME. IN PARTICULAR, NUMBERS OVER 5000.\n";
|
||||
|
||||
my $X;
|
||||
my $Z;
|
||||
do {
|
||||
for (my $Q=1; $Q<=12; $Q++) {
|
||||
$F[$Q]=0;
|
||||
}
|
||||
print "\n"; print "HOW MANY ROLLS";
|
||||
print "? "; chomp($X = <STDIN>);
|
||||
for (my $S=1; $S<=$X; $S++) {
|
||||
my $A=int(6*rand(1)+1);
|
||||
my $B=int(6*rand(1)+1);
|
||||
my $R=$A+$B;
|
||||
$F[$R]=$F[$R]+1;
|
||||
}
|
||||
print "\n";
|
||||
print "TOTAL SPOTS\tNUMBER OF TIMES\n";
|
||||
for (my $V=2; $V<=12; $V++) {
|
||||
print "$V\t\t$F[$V]\n";
|
||||
}
|
||||
print "\n";
|
||||
print "\n"; print "TRY AGAIN";
|
||||
print "? "; chomp($Z = <STDIN>);
|
||||
} until (uc($Z) ne "YES");
|
||||
exit;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user