Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others contemplating the Monastery: (3)
    As of 2014-07-13 00:35 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      When choosing user names for websites, I prefer to use:








      Results (242 votes), past polls