Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Sainthood via Seniority Simulation

by sauoq (Abbot)
on Nov 05, 2003 at 10:56 UTC ( #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.";


Comment on Re: Sainthood via Seniority Simulation
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (17)
As of 2015-07-28 16:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (258 votes), past polls