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

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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.";

In reply to Re: Sainthood via Seniority Simulation by sauoq
in thread Sainthood via Seniority Simulation by ysth

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2023-03-28 11:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (67 votes). Check out past polls.

    Notices?