Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Sainthood via Seniority Simulation

by ysth (Canon)
on Nov 05, 2003 at 03:26 UTC ( [id://304610]=monkdiscuss: print w/replies, xml ) Need Help??

Show up every day, punch in your votes, and you too, yes you, can be a saint.

Update: See Re: Sainthood via Seniority Simulation for a new version for the expanded level system.

#!/usr/bin/perl use warnings; use strict; use Lingua::EN::Inflect 'A'; my ($day, $level, $xp); $level = {xp => 0, votes => 0, title => "initiate", next => {xp => 20, votes => 5, title => "novice", next => {xp => 50, votes => 8, title => "acolyte", next => {xp => 100, votes => 12, title => "scribe", next => {xp => 200, votes => 16, title => "monk", next => {xp => 500, votes => 20, title => "friar", next => {xp => 1000, votes => 25, title => "abbot", next => {xp => 1600, votes => 30, title => "bishop", next => {xp => 2300, votes => 35, title => "pontiff", next => {xp => 3000, votes => 40, title => "saint"}}}}}}}}}}; $| = 1; print "Enter your current xp: "; chomp($xp = <STDIN>); die "Doesn't look quite like an xp to me\n" if $xp ne do { no warnings 'numeric'; 0+$xp }; $day = 0; while ($level->{next}) { # bonus for casting all votes (through level 5) $xp += int($level->{votes}/6) if $day > 0 && $level->{votes} < 16; + # (update:corrected from <= 16) ($level = $level->{next}) and print("Day $day: you are ", A($level->{title}), "\n") while $level->{next} && $xp >= $level->{next}{xp}; ++$day; # 25% chance for each vote cast (rand(4) < 1) and ++$xp for 1..$level->{votes}; # 25% chance for 2 xp for logging in (rand(4) < 1) and $xp += 2; }

Replies are listed 'Best First'.
Re: Sainthood via Seniority Simulation
by perrin (Chancellor) on Nov 05, 2003 at 04:24 UTC
    And if you do show up every day, and vote intelligently, you deserve to be a saint. Voters are important, or so they told me at my polling place in Brooklyn this morning.
      And if you do show up every day, and vote intelligently, you deserve to be a saint.
      Of course, the person who casts all his N votes on the first N posts he encounters (and casts all of them --) gets rewarded as much as casting them by any other strategy.

      Perlmonks rewards voting, and it doesn't discriminate between an "intelligent" vote and a "vote to get XP".

      Voters are important, or so they told me at my polling place in Brooklyn this morning.
      But any democracy who doesn't want to be become the laughing stock of the world doesn't hand out goodies in the voting boots.

      Abigail

        Interestingly, quite a number of countries have compulsary voting. According to this list, at least 15 countries have a fine for not voting, and in 3, you can actualy be imprisioned for it. This seems tantamount to handing out goodies in the voting booths.

        As to your first point, there's little way to tell the difference between somebody voting randomly and somebody voting intelegently. I'm told that there are some statistical analisies performed to catch potential votebots, however I can't discuss the details (because I don't know them).


        Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

        Perlmonks rewards voting, and it doesn't discriminate between an "intelligent" vote and a "vote to get XP".
        This is consistent with governments the world over.
        But any democracy who doesn't want to be become the laughing stock of the world doesn't hand out goodies in the voting booths.
        (Spelling error corrected for clarity)
        I've always wondered why this is. I suspect that a free buffet lunch at a polling location would draw in registered voters like flies. They check your registration, you vote, you go around the buffet once or twice.

        Yeah, voters shouldn't have to be enticed. Humanity shouldn't have to be policed, either, but those systems exist. Necessary evils exist, so why encourage only the most egregious ones? Why shouldn't there be tasty baked lasagna, free for the taking if you do your civic duty?



        -----------------------
        You are what you think.

          A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Sainthood via Seniority Simulation
by pg (Canon) on Nov 05, 2003 at 06:04 UTC

    The logic is a little bit off in the while loop ;-)

    If during the day, you advance to the next level, number of votes you can cast for that day is still based on your previous day's level.

    However in your script, you do $level = $level->{next} first, and then right the way started to use $level->{votes}, which is the number of votes for the new level.

    Not much difference in terms of the final results, especially take all the rand() into consideration, but the simulation is not precise.

      I'm not sure I understand you. Can you explain in code or pseudocode? My intent was that everything in the loop after the ++$day is events occurring during the course of a day. Before ++$day is events occurring at the end of a day. (This doesn't correctly model exactly when the level actually changes, but I think it does use fields based on the correct level everywhere.)
        People didn't seem to like my asking for further explanation :(. I still don't see the bug, though I see my loop is written in a rather confusing way :(. I'm trying to compare what I have with sauoq's version. The first difference I see is whether the day number is printed just before or just after incrementing, which is really a cosmetic issue. We also differ on if the "used all votes" bonus applies to monks; Voting/Experience System could be read either way. (update: monks(5) don't seem to get the bonus--updating my version now)

        my version:

        increment level if appropriate increment day add per-vote xp add login xp add all-votes-used xp repeat
        sauoq's version:
        increment day increment level if appropriate add login xp add per-vote xp add all-votes-used xp repeat
Re: Sainthood via Seniority Simulation
by sauoq (Abbot) on Nov 05, 2003 at 10:56 UTC

    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.";
    
Re: Sainthood via Seniority Simulation
by delirium (Chaplain) on Nov 05, 2003 at 12:59 UTC
    I think Sainthood can be acheived faster by posting good material, which other users will ++.

    If you wanted to cheat, maybe script a supersearch of root nodes from tilly|tye|davorg|merlyn|pg|davido from a year ago and repost them.

    It may be even quicker to just bribe Vroom. My paltry $200 got me Friar, which comes to about 40 cents per XP.

      A couple of picky remarks.

      1. One year ago, tilly was still missing.
      2. Pg arrived less than one year before your post.
      3. davido came to the Monastery in August. Hard to find his nodes from a year ago.
      4. Copying some of davido's nodes will give you trouble rather than fame and fortune. What do I mean? List his nodes by lowest reputation and read them.

      HTH

Re: Sainthood via Seniority Simulation
by ysth (Canon) on Nov 05, 2003 at 05:34 UTC
    I guess I need to provide a rationale for this post. I had planned to originally, but discovered I really had many different things in mind all at once. Here are some thoughts, in no particular order:

    I was kind of intrigued yet not entangled by the XP system and I read why did i get downvoted? which seemed to make a lot of sense, particularly as I was seeing little or no correspondence between my self-judgement of my posts and their reputation. I also ran across some (positive) comments about XP Whores which I thought of as an amusing concept. Then I discovered "XP Whore" feelings lurking in my own psyche. I hoped this simulation would fatally puncture them (but it has not come to pass).

    I also was thinking about the different kinds of contribution to this kind of community, whether poster, maintainer, reader and wanted to highlight the reward for the contribution of just being there day by day and sharing opinions, if only via those little ++ and --'s.

    I also found the description of the XP system to be just a little vague and wanted to formalize my interpretation of it and see if I got corrections. (E.g. what is 1/6th of 16, or of 5, anyway?)

    And I wanted to provoke some smiles. BTW, it seems to take between 450 and 500 days to go from initiate to saint.

    And last of all, I was hoping for some votes so I could advance a level really soon now. :)

      And last of all, I was hoping for some votes so I could advance a level really soon now. :)

      My experience has been, nothing gets you XP faster than posting a good obfuscation. (Then again, maybe it's just that I'm better at obfuscation than other types of contribution... What does that say about me?)


      $;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/

        I thought that too first. But now I see that discovering an important bug (or something that seems like a bug) in Perl core gives you even more.

Re: Sainthood via Seniority Simulation
by zentara (Cardinal) on Nov 05, 2003 at 17:59 UTC
    I think reading and voting for nodes is "not the best" method of moving towards Sainthood, but what else is there? Even if you don't grasp the full contents of the nodes, repeatedly reading the perlmonks nodes, will impart a "feel" for what the basic problems are in writing Perl code. I find myself seeing a problem, and thoughts pop into my head...."oh yeah, I seem to remember Abigail, BrowserUk, Aristotle or some of the other great ones, discussed this, and came to "some general conclusion". So even if I don't become as proficient a programmer as them, I do have a better idea of "where to look for answers". Some saints are going to be "Perl managers", instead of "Perl programmers".

    As far as the quickest way to Sainthood goes, why not adopt the "capitalist method"......buy yourself a superfast server and offer to let vroom use it for free, if they make you a "saint". Sort of like a "Perl oligarch". :-)

Re: Sainthood via Seniority Simulation
by planetscape (Chancellor) on Nov 11, 2005 at 01:53 UTC

    A trivial update for the new system:

    #!/usr/bin/perl use warnings; use strict; use Lingua::EN::Inflect 'A'; my ($day, $level, $xp); $level = {xp => 0, votes => 0, title => "Initiate", next => {xp => 20, votes => 2, title => "Novice", next => {xp => 50, votes => 4, title => "Acolyte", next => {xp => 90, votes => 6, title => "Sexton", next => {xp => 150, votes => 8, title => "Beadle", next => {xp => 250, votes => 10, title => "Scribe", next => {xp => 400, votes => 12, title => "Monk", next => {xp => 600, votes => 14, title => "Pilgrim", next => {xp => 900, votes => 16, title => "Friar", next => {xp => 1300, votes => 18, title => "Hermit", next => {xp => 1800, votes => 20, title => "Chaplain", next => {xp => 2400, votes => 22, title => "Deacon", next => {xp => 3000, votes => 24, title => "Curate", next => {xp => 4000, votes => 26, title => "Priest", next => {xp => 5400, votes => 28, title => "Vicar", next => {xp => 7000, votes => 30, title => "Parson", next => {xp => 9000, votes => 32, title => "Prior", next => {xp => 12000, votes => 34, title => "Monsignor", next => {xp => 16000, votes => 36, title => "Abbot", next => {xp => 22000, votes => 38, title => "Canon", next => {xp => 30000, votes => 40, title => "Chancellor", next => {xp => 40000, votes => 42, title => "Bishop", next => {xp => 50000, votes => 44, title => "Archbishop", next => {xp => 60000, votes => 46, title => "Cardinal", next => {xp => 70000, votes => 48, title => "Sage", next => {xp => 80000, votes => 50, title => "Saint", next => {xp => 90000, votes => 52, title => "Apostle", next => {xp => 100000, votes => 54, title => "Pope"}}}}}}}}}}}}}}}}}} +}}}}}}}}}}; $| = 1; print "Enter your current xp: "; chomp($xp = <STDIN>); die "Doesn't look quite like an xp to me\n" if $xp ne do { no warnings 'numeric'; 0+$xp }; $day = 0; while ($level->{next}) { # bonus for casting all votes (through level 5) $xp += int($level->{votes}/6) if $day > 0 && $level->{votes} < 10; + ($level = $level->{next}) and print("Day $day: you are ", A($level->{title}), "\n") while $level->{next} && $xp >= $level->{next}{xp}; ++$day; # 25% chance for each vote cast (rand(4) < 1) and ++$xp for 1..$level->{votes}; # 25% chance for 2 xp for logging in (rand(4) < 1) and $xp += 2; }

    Now repeat after me: "I am not an XP whore... I am not an XP whore..." ;-)

    planetscape
      Thanks for saving me the trouble of doing this. An average of 10 runs shows 22.46 years to reach Saint :)

        Och. It was no tribble at all... ;-)

        planetscape

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-11-01 19:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    chatterbot is...






    Results (6 votes). Check out past polls.