Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

What the other half does

by lzcd (Pilgrim)
on Jan 05, 2001 at 04:47 UTC ( [id://49937]=perlmeditation: print w/replies, xml ) Need Help??

In a bout of work inspired boredom and ‘green on black’ terminal nostalgia I ask the world at large:

What is the sexiest game written in Perl?

I ask not out of profit or troll. Merely in an effort to explore yet another facet of Perldom.

Is there an online RPG that’s had you gobsmacked and bleary eyed for the last 3 months?
Is there a new improved way to practice the old arts likes Wumpus hunting or Zork mastery?
Does your weekend begin with #!/usr/bin/perl?

Thank you for your frontal lobe time.

Replies are listed 'Best First'.
Re: What the other half does
by myocom (Deacon) on Jan 05, 2001 at 04:54 UTC

    Though I've never tested it, there is a z-machine interpreter for Infocom games, written in Perl. You can find it here. I leave finding the games as an exercise for the reader.

Re: What the other half does
by lemming (Priest) on Jan 05, 2001 at 05:51 UTC
    I used to play with the TK Tetris from the Cookbook.
    chromatic, IIRC, mentioned he was working on a perl based rogue. That would be very cool.
    I've used Perl for keeping track of various gaming stats from before. I used to be addicted to crack, I mean Magic and had a flat database.
    I'm currently converting a C++ program for generating random Champions characters. (Poor time management on my end is thwarting me.)
Re: What the other half does
by TStanley (Canon) on Jan 05, 2001 at 09:44 UTC
    I wrote a simple program in perl to generate character stats for Advanced Dungeons
    And Dragons. It works for the most part, but could use some fine tuning. All of the die
    rolls are somewhat on the high side, and not at all what actually rolling three six-sided dice
    would produce. However, if you want some high end characters, its exactly what you need. :)

    TStanley
    There can be only one!

    #!/usr/bin/perl use strict -w; sub Random () { my $randnum = int (rand(18))+1; return $randnum; } my $x=0; while ($x<=5) { @STR[$x]=Random(); @INT[$x]=Random(); @WIS[$x]=Random(); @DEX[$x]=Random(); @CON[$x]=Random(); @CHR[$x]=Random(); $x++; } print("Strength:\t\t"); my $x=0; while($x<=@STR) { print ("$STR[$x]\t"); $x++; } print("\n"); print("Intelligence:\t\t"); my $x=0; while($x<=@INT) { print ("$INT[$x]\t"); $x++; } print("\n"); print("Wisdom:\t\t\t"); my $x=0; while($x<=@WIS) { print ("$WIS[$x]\t"); $x++; } print("\n"); print("Dexterity:\t\t"); my $x=0; while($x<=@DEX) { print ("$DEX[$x]\t"); $x++; } print("\n"); print("Constitution:\t\t"); my $x=0; while($x<=@CON) { print ("$CON[$x]\t"); $x++; } print("\n"); print("Charisma:\t\t"); my $x=0; while($x<=@CHR) { print ("$CHR[$x]\t"); $x++; } print("\n");

      All of the die rolls are somewhat on the high side, and not at all what actually rolling three six-sided dice would produce.

      I don't really see how they come out high on average - all that happens is that they come out fairly evenly spread over the entire range, whereas you get more of a bell-curve of probability with 3x6-sided...

      In terms of "fine tuning", you should really turn some of that into loops. You're doing pretty much the same thing over and over again:

      foreach (qw/Strength Intelligence Wisdom Dexterity Constitution Charisma/) { printf "%-15s", $_; for (1 .. 6) { printf "%2d\t", int(rand(6)) + int(rand(6)) + int(rand(6)) + 3; } print "\n"; }

      Or:

      printf "%s\t%s\n", $_, join "\t", map { int(rand(6)) + int(rand(6)) + int(rand(6)) + 3 } (1 .. 6) for (qw/Str Int Wis Dex Con Chr/);

      Tony

        Thank you for your suggestion. I will definitely do that.

        TStanley
        There can be only one!
      Another way of doing the same thing:
      #!/usr/bin/perl use strict; ##################### Script Constants ###################### use constant CHARACTER_STATS => qw(Strength Intelligence Wisdom Dexter +ity Constitution Charisma); ################### Main Program ############################ MAIN: { my $character = make_character(); foreach my $stat (keys %$character) { print STDOUT ("$stat: \t\t", join("\t", @{ $character->{$stat} }), "\n" ); } } sub make_character { my $character = {}; for (my $x = 0; $x<=5; $x++) { foreach my $stat ( CHARACTER_STATS ) { push(@{$character->{$stat}}, Random()); } } return $character; } sub Random () { return (int (rand(18))+1); }
      If you're interested in having the dice follow a normal distribution, check out the Math::Random module.

      stephen

(fongsaiyuk)Re: What the other half does
by fongsaiyuk (Pilgrim) on Jan 06, 2001 at 02:01 UTC
    Heh... When I first read this node's subject, I though you were referring to a potential significant other! ie. "the other half"

    ^-^

    BTW, the other hemisphere seeks to be a manga artist...

    fongsaiyuk

      Okay... For those who like a more 'lovey dovely' aspect to their Monastery life: :)

      What's your partners favourite perl game?

      ... or has anybody lost a partner due to a perl game? :)

        My partner's favorite Perl game is the one where I do the dishes and she sits in judgement. Of course, that is merely a fantasy game and I don't play fantasy games -- nevertheless, she continues to play ... and I continue to lose points...
        :-(

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2024-04-24 22:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found