[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[FWP] Perl Card Games



I was playing war with my nephew this weekend. He's pretty smart for a
seven-year-old, and he quickly realized that---rather than painstakingly
showing each other one card at a time---we could line up all of our cards in
a row, compare them all (with a "war" meaning we would compare the 4th card
down the line) and then divvy up the cards for the next round. I nonetheless
got pretty bored after a couple rounds and wished I could get a computer to
do it for me.

So on Sunday I wrote up CardGame.pm, a module for card games, and war.pl,
which plays war. (In fact, war.pl plays both sides, which saves the players
lots of effort, I figure.)

I wouldn't have posted it to the list, since it's basically a shameless
plug, but:

(1) we had a card game thread here recently
(2) a recent TPJ contest involved cards
(3) the Games:: section on CPAN is pretty sparse right now, and didn't have
any card stuff on it
(4) I'm hoping someone from the list will download it and tell me I'm a
Brilliant Hacker (tm)

But most importantly:

(5) card games are fun, and I wrote this in Perl, so it's Fun with Perl. Um,
kind of.

If anyone cares, I put the module and game in
http://voth.hec.utah.edu/~karger/download

It only took me a couple hundred lines for CardGame.pm (although I added 200
lines of pod for Good Style (tm) practice), and a hundred for war. Given the
characteristics of this group's readers, I assume someone will upload a
50-line war including a GUI interface within a couple days. If I find
nothing better to do with my time, I may try to create a
Term::Readline-based Solitaire.

Warning: this module is pre-alpha. Using it to play cards on DOD computers
controlling nuclear missles could be hazardous to my health.

-Amir Karger
karger@post.harvard.edu

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe