NAME
Games::Euchre - Euchre card game for humans and computers
SYNOPSIS
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");
DESCRIPTION
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.
CLASS METHODS
- new
-
Create and initialize a new Euchre game.
INSTANCE METHODS
Pre-Game methods
- enableHangDealer
-
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.
- enableNoTrump
-
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".
- setAI INDEX AI_OBJECT
-
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.
Game Methods
- resetGame
-
Clear all of the state for the current game and get ready for the next one.
- resetHand
-
Clear all of the state for the current hand and get ready for the next one.
- playGame
-
Start a game.
- playHand
-
Start a hand. Called from playGame().
- getBid
-
Called from playHand().
- nextDealer
-
Called from playHand().
- setTrump TRUMPSUIT
-
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().
- getNewTrick LEADPLAYER TURNNUMBER
-
Instantiate and return a new Games::Euchre::Trick object. Called from playHand().
- scoreHand
-
At the end of a hand, update the scores for the teams.
- computeHandScores
-
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().
- computeWinTypes
-
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().
- announceEndOfBidding
-
Tell AIs the results of the bidding.
- announceEndOfTrick TRICK
-
Tell AIs the results of the trick.
- announceEndOfHand
-
Tell AIs the results of the hand.
- announceEndOfGame
-
Tell AIs the results of the game.
Utility/Access Methods
- getWinner
-
Returns the Team object who has won the game, or undef if nobody has won yet.
- getTeams
-
Returns an array of two Team objects.
- getPlayers
-
Returns an array of four Player objects.
- getPlayerNames
-
Returns a hash relating player numbers to player names for all four players.
- getScores
-
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.
- getCardSuit CARD
-
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().]
SEE ALSO
Games::Cards by Amir Karger
LICENSE
GNU Public License, version 2
AUTHOR
Chris Dolan, chrisdolan@users.sourceforge.net