sub score { # score is reported in millions. my $t = .1; # there is an actual minimum score. my $b = 0; # this counts the balls. my $round = 0; while (++$round) { # it's a 3 ball table, so ... last if $b > 3; # get some points, $t += int(rand $round*10)/10; # risk draining (++$b && redo) if (int rand int sqrt (9*$round)); # possibly get an extra ball $b-- unless int rand(5); # get the big points if we made it this far $t += 2 * $round; # the rest of this isn't interesting # let me know if something too unlikely happens... print ("Divine Intervention: $t points in $round rounds.\n") and last if not $round % 20; # ... and stop it if it gets out of hand print ("Apocolypse!") and last if $round > 400; } # point out statistically unlikely games; # otoh, they should range up to 200 ~ .01% of the time, # and some real games do fail to get off the ground. warn "Great game: $t in $round!\n" if ($round > 12 or $t > 150); warn "Horrid try: $t in $round!\n" if ($round < 1 or $t < .2); return $t; }