Games::Euchre - Euchre card game for humans and computers
Simply run my game wrapper:
% euchre.pl
or write your own:
use Games::Euchre; use Games::Euchre::AI::Simple; use Games::Euchre::AI::Human; my $game = Games::Euchre->new(); foreach my $i (1..3) { $game->setAI($i, Games::Euchre::AI::Simple->new()); } $game->setAI(4, Games::Euchre::AI::Human->new()); $game->playGame(); my @scores = sort {$b <=> $a} $game->getScores(); print("The winner is " . $game->getWinner()->getName() . " with a score of " . "$scores[0] to $scores[1]\n");
This software implements the card game of Euchre. The game is played with four players composing two teams. Any of the four players can be human or computer players, but more than one human is not well supported yet.
The Games::Euchre::AI module implements a simple framework for adding new classes of human interfaces or computer opponents. I recomment that AI writers use Games::Euchre::AI::Simple (a REALLY dumb computer opponent) as starting point.
Aside from the ::AI class and its descendents, this package also implements the following classes: Games::Euchre::Team, Games::Euchre::Player and Games::Euchre::Trick.
Create and initialize a new Euchre game.
Turns on the hang-the-dealer game option. It is off by default. If on, this means that the dealer may not pass in the second bidding round. Otherwise, the deal passes to the next player and bidding begins anew.
Turns on the no-trump game option. It is off by default. If on, this means that in the second round of bidding, players may declare "No trump".
Tells the game to use the specified AI instance to control the player of the given index. The index must be an integer between 1 and 4. The AI instance must inherit from Games::Euchre::AI.
Clear all of the state for the current game and get ready for the next one.
Clear all of the state for the current hand and get ready for the next one.
Start a game.
Start a hand. Called from playGame().
Called from playHand().
Records the trump suit for this hand. Also computes the suit of the left jack for convenience. No-trump is handled correctly. Called from getBid().
Instantiate and return a new Games::Euchre::Trick object. Called from playHand().
At the end of a hand, update the scores for the teams.
At the end of a hand, compute how many points each team deserves to gain for the tricks they won. Returns an array of these score increments. This method does not record any changes at all. Called by scoreHand().
At the end of a hand, compute what type of result each team deserves to gain for the tricks they won: one of 'win', 'all', 'alone', or 'euchre'. Returns an array of these win types increments. This method does not record any changes at all. Called by computeHandScores().
Tell AIs the results of the bidding.
Tell AIs the results of the trick.
Tell AIs the results of the hand.
Tell AIs the results of the game.
Returns the Team object who has won the game, or undef if nobody has won yet.
Returns an array of two Team objects.
Returns an array of four Player objects.
Returns a hash relating player numbers to player names for all four players.
Returns an array of current scores for the two teams. The order of the returned scores is the same as the order of the returned teams in the getTeams() method.
Returns the suit of the given card. The left jack is reported to be of the trump suit, if a trump has been declared. [This latter convenience is the whole point of having this function at all and not just calling CARD->suit().]
Games::Cards by Amir Karger
GNU Public License, version 2
Chris Dolan, chrisdolan@users.sourceforge.net
To install Games::Euchre, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Games::Euchre
CPAN shell
perl -MCPAN -e shell install Games::Euchre
For more information on module installation, please visit the detailed CPAN module installation guide.