diff --git a/62_Mugwump/perl/mugwump.pl b/62_Mugwump/perl/mugwump.pl index d02a9036..33835b77 100755 --- a/62_Mugwump/perl/mugwump.pl +++ b/62_Mugwump/perl/mugwump.pl @@ -1,96 +1,96 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -# global variables defined here -my(@MUGWUMP) = (); - -# subroutines defined here - -# init_mugwump: pick the random places for the Mugwumps -sub init_mugwump() { - @MUGWUMP = (); - for (1 .. 4) { - push @MUGWUMP, [ int(rand 10), int(rand 10) ]; - } -} - - -# main code starts here - -# print introductory text -print <); - my($M,$N) = split(/,/,$in); - $M = int($M); - $N = int($N); - - for my $i (0 .. $#MUGWUMP) { - # -1 indicates a Mugwump that was already found - next if $MUGWUMP[$i]->[0] == -1; - - if ($MUGWUMP[$i]->[0] == $M && $MUGWUMP[$i]->[1] == $N) { - $MUGWUMP[$i]->[0] = -1; - printf("You have found Mugwump %d\n", $i+1); - } else { - my $d = sqrt(($MUGWUMP[$i]->[0] - $M) ** 2 + ($MUGWUMP[$i]->[1] - $N) ** 2); - printf("You are %.1f units away from Mugwump %d\n", $d, $i+1); - } - } - - # If a Mugwump still has not been found, - # go to the next turn - for my $j (0 .. $#MUGWUMP) { - if ($MUGWUMP[$j]->[0] != -1) { - next TURN; - } - } - # You win! - printf("You got all of them in %d %s!\n\n", $turn, ($turn == 1 ? 'turn' : 'turns')); - # Pass execution down to the continue block - next PLAY; - - } # end of TURN loop - - print "\nSorry, that's 10 tries. Here's where they're hiding:\n"; - for my $i (0 .. $#MUGWUMP) { - printf("Mugwump %d is at (%d, %d)\n", $i+1, $MUGWUMP[$i]->[0], $MUGWUMP[$i]->[1]) - if $MUGWUMP[$i]->[0] != -1; - } -} -continue { - print "\nThat was fun! Let's play again.......\n"; - print "Four more Mugwumps are now in hiding.\n\n"; -} - +#!/usr/bin/perl + +use strict; +use warnings; + +# global variables defined here +my(@MUGWUMP) = (); + +# subroutines defined here + +# init_mugwump: pick the random places for the Mugwumps +sub init_mugwump() { + @MUGWUMP = (); + for (1 .. 4) { + push @MUGWUMP, [ int(rand 10), int(rand 10) ]; + } +} + + +# main code starts here + +# print introductory text +print <); + my($M,$N) = split(/,/,$in); + $M = int($M); + $N = int($N); + + for my $i (0 .. $#MUGWUMP) { + # -1 indicates a Mugwump that was already found + next if $MUGWUMP[$i]->[0] == -1; + + if ($MUGWUMP[$i]->[0] == $M && $MUGWUMP[$i]->[1] == $N) { + $MUGWUMP[$i]->[0] = -1; + printf("You have found Mugwump %d\n", $i+1); + } else { + my $d = sqrt(($MUGWUMP[$i]->[0] - $M) ** 2 + ($MUGWUMP[$i]->[1] - $N) ** 2); + printf("You are %.1f units away from Mugwump %d\n", $d, $i+1); + } + } + + # If a Mugwump still has not been found, + # go to the next turn + for my $j (0 .. $#MUGWUMP) { + if ($MUGWUMP[$j]->[0] != -1) { + next TURN; + } + } + # You win! + printf("You got all of them in %d %s!\n\n", $turn, ($turn == 1 ? 'turn' : 'turns')); + # Pass execution down to the continue block + next PLAY; + + } # end of TURN loop + + print "\nSorry, that's 10 tries. Here's where they're hiding:\n"; + for my $i (0 .. $#MUGWUMP) { + printf("Mugwump %d is at (%d, %d)\n", $i+1, $MUGWUMP[$i]->[0], $MUGWUMP[$i]->[1]) + if $MUGWUMP[$i]->[0] != -1; + } +} +continue { + print "\nThat was fun! Let's play again.......\n"; + print "Four more Mugwumps are now in hiding.\n\n"; +} + diff --git a/76 Russian Roulette/perl/russianroulette.pl b/76 Russian Roulette/perl/russianroulette.pl new file mode 100644 index 00000000..0fa0cff7 --- /dev/null +++ b/76 Russian Roulette/perl/russianroulette.pl @@ -0,0 +1,39 @@ +#!/usr/bin/perl +#use strict; +# Automatic converted by bas2perl.pl + +print ' 'x28 . "RUSSIAN ROULETTE\n"; +print ' 'x15 . "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY\n"; +print "\n"; print "\n"; print "\n"; +print "THIS IS A GAME OF >>>>>>>>>>RUSSIAN ROULETTE.\n"; +Line10: +print "\n"; print "HERE IS A REVOLVER.\n"; +Line20: +print "TYPE '1' TO SPIN CHAMBER AND PULL TRIGGER.\n"; +print "TYPE '2' TO GIVE UP.\n"; +print "GO"; +$N=0; +Line30: +print "? "; chomp($I = ); +if ($I ne 2) { goto Line35; } +print " CHICKEN!!!!!\n"; +goto Line72; +Line35: +$N=$N+1; +if (rand(1)>.833333) { goto Line70; } +if ($N>10) { goto Line80; } +print "- CLICK -\n"; +print "\n"; goto Line30; +Line70: +print " BANG!!!!! YOU'RE DEAD!\n"; +print "CONDOLENCES WILL BE SENT TO YOUR RELATIVES.\n"; +Line72: +print "\n"; print "\n"; print "\n"; +print "...NEXT VICTIM...\n"; goto Line20; +Line80: +print "YOU WIN!!!!!\n"; +print "LET SOMEONE ELSE BLOW HIS BRAINS OUT.\n"; +goto Line10; +exit; + +