Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Sainthood via Seniority Simulation

by sauoq (Abbot)
on Nov 05, 2003 at 10:56 UTC ( [id://304674]=note: print w/replies, xml ) Need Help??


in reply to Sainthood via Seniority Simulation

Here it is rewritten for clarity and to fix the bug pg reported. Also, it now supports level vroom and doesn't require a non-standard prerequisite.

#!/usr/bin/perl use warnings; use strict; my $USAGE =<<END_USAGE; $0 your_xp [ vrooms_xp ] END_USAGE sub XP () { 0 } sub VOTES () { 1 } sub DESC () { 2 } my @LEVEL = ( [ 0, 0, 'an initiate' ], [ 20, 5, 'a novice' ], [ 50, 8, 'an acolyte' ], [ 100, 12, 'a scribe' ], [ 200, 16, 'a monk' ], [ 500, 20, 'a friar' ], [ 1000, 25, 'an abbot' ], [ 1600, 30, 'a bishop' ], [ 2300, 35, 'a pontiff' ], [ 3000, 40, 'a saint' ], ); die $USAGE unless @ARGV >= 1 and @ARGV <= 2; my $xp = shift; my $level = 0; push @LEVEL, [ pop, 42, 'the one and only vroom' ] if @ARGV; my $day = 0; do { $day++; # Anyone remember One Day at a Time? # What level are we today? while ($LEVEL[ $level + 1 ] and $xp >= $LEVEL[ $level + 1 ]->[ XP +]) { $level++; printf "Day %5d You are %s.\n", $day, $LEVEL[ $level ]->[ DESC + ]; } # %25 chance of 2xp for showing up. int rand( 4 ) or $xp += 2; # %25 chance of 1xp for every vote. int rand( 4 ) or $xp++ for 1 .. $LEVEL[ $level ]->[ VOTES ]; # 1/6 * votes * 1xp for pre-friars. $xp += int ( $LEVEL[ $level ]->[ VOTES ] / 6 ) if $level < 4; } until ( $level == $#LEVEL );
-sauoq
"My two cents aren't worth a dime.";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://304674]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-10-06 11:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (43 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.