org.jscience.computing.game.cards
Class BlackJack

java.lang.Object
  extended by org.jscience.computing.game.AbstractGame
      extended by org.jscience.computing.game.cards.BlackJack
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, GamePlay

public class BlackJack
extends AbstractGame

BlackJack implements the rules for playing BlackJack. The casino rules of the game are embedded in this class with the implementations of listLegalMoves(), dealerMove() and getResult(int playerRole). Todo for a future version: strip out casino rules and make them available as options that can be changed through public methods.

See Also:
Serialized Form

Field Summary
static int BURN_CARDS
          DOCUMENT ME!
static int MINIMUM_CARDS
          DOCUMENT ME!
static int NUMBER_OF_DECKS
          DOCUMENT ME!
 
Constructor Summary
BlackJack()
          Creates a new BlackJack object.
BlackJack(CardDeck deck, float[] bet)
          Creates a new BlackJack object.
BlackJack(CardDeck deck, float[] bet, java.util.Random random)
          Creates a new BlackJack object.
BlackJack(float bet)
          Creates a new BlackJack object.
BlackJack(float[] bet)
          Creates a new BlackJack object.
BlackJack(float[] bet, java.util.Random random)
          Creates a new BlackJack object.
 
Method Summary
 java.lang.Object clone()
          Note: the cloned object will have a separate Random object assiciated with it, so that operations on the cloned object will not affect the random numbers of the original.
 boolean gameOver()
          DOCUMENT ME!
static int getCardValue(Card card, boolean softCount)
          DOCUMENT ME!
 org.jscience.computing.game.cards.BJHand getCurrentHand(int playerRole)
          getCurrentHand() is internally a wrapper which returns a clone of the actual BJHand used in the game
 java.util.Vector<Card> getDealerCards()
          DOCUMENT ME!
 CardDeck getDeck()
          DOCUMENT ME!
static int getHandValue(java.util.Collection cards)
          DOCUMENT ME!
 Card getOpenDealerCard()
          DOCUMENT ME!
 double getResult(int playerRole)
          DOCUMENT ME!
 int[] getWinner()
          DOCUMENT ME!
static boolean isBlackJack(java.util.Collection cards)
          Note that a Vector of cards may not be considered BlackJack even though this function returns true, which is the case if the particular hand is derived from an Ace split.
static boolean isSoft(java.util.Collection cards)
          DOCUMENT ME!
protected  GameMove[] listLegalMoves()
          DOCUMENT ME!
 int nextPlayer()
          DOCUMENT ME!
protected  boolean popMove()
          DOCUMENT ME!
protected  boolean pushMove(GameMove move)
          DOCUMENT ME!
 java.lang.String toString()
          DOCUMENT ME!
 
Methods inherited from class org.jscience.computing.game.AbstractGame
clearRedoList, getGameName, getLastMove, getLastPlayer, getLegalMoves, getLegalMoves, getMoveHistory, getNumberOfRedoMoves, getRedoList, isLegalMove, isWinner, loadFromFile, makeMove, numberOfMoves, numberOfPlayers, redoMove, resetLegalMoves, resetLists, saveToFile, spawnChild, undoLastMove, undoMoves
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NUMBER_OF_DECKS

public static int NUMBER_OF_DECKS
DOCUMENT ME!


MINIMUM_CARDS

public static int MINIMUM_CARDS
DOCUMENT ME!


BURN_CARDS

public static int BURN_CARDS
DOCUMENT ME!

Constructor Detail

BlackJack

public BlackJack()
Creates a new BlackJack object.


BlackJack

public BlackJack(float bet)
Creates a new BlackJack object.

Parameters:
bet - DOCUMENT ME!

BlackJack

public BlackJack(float[] bet)
Creates a new BlackJack object.

Parameters:
bet - DOCUMENT ME!

BlackJack

public BlackJack(float[] bet,
                 java.util.Random random)
Creates a new BlackJack object.

Parameters:
bet - DOCUMENT ME!
random - DOCUMENT ME!

BlackJack

public BlackJack(CardDeck deck,
                 float[] bet)
Creates a new BlackJack object.

Parameters:
deck - DOCUMENT ME!
bet - DOCUMENT ME!

BlackJack

public BlackJack(CardDeck deck,
                 float[] bet,
                 java.util.Random random)
Creates a new BlackJack object.

Parameters:
deck - DOCUMENT ME!
bet - DOCUMENT ME!
random - DOCUMENT ME!
Method Detail

getOpenDealerCard

public Card getOpenDealerCard()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getDealerCards

public java.util.Vector<Card> getDealerCards()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getDeck

public CardDeck getDeck()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getCurrentHand

public org.jscience.computing.game.cards.BJHand getCurrentHand(int playerRole)
getCurrentHand() is internally a wrapper which returns a clone of the actual BJHand used in the game

Parameters:
playerRole - DOCUMENT ME!
Returns:
DOCUMENT ME!

getHandValue

public static int getHandValue(java.util.Collection cards)
DOCUMENT ME!

Parameters:
cards - DOCUMENT ME!
Returns:
DOCUMENT ME!

isSoft

public static boolean isSoft(java.util.Collection cards)
DOCUMENT ME!

Parameters:
cards - DOCUMENT ME!
Returns:
DOCUMENT ME!

getCardValue

public static int getCardValue(Card card,
                               boolean softCount)
DOCUMENT ME!

Parameters:
card - DOCUMENT ME!
softCount - DOCUMENT ME!
Returns:
DOCUMENT ME!

isBlackJack

public static boolean isBlackJack(java.util.Collection cards)
Note that a Vector of cards may not be considered BlackJack even though this function returns true, which is the case if the particular hand is derived from an Ace split.

Parameters:
cards - DOCUMENT ME!
Returns:
DOCUMENT ME!

gameOver

public boolean gameOver()
DOCUMENT ME!

Overrides:
gameOver in class AbstractGame
Returns:
DOCUMENT ME!

getWinner

public int[] getWinner()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getResult

public double getResult(int playerRole)
DOCUMENT ME!

Specified by:
getResult in interface GamePlay
Overrides:
getResult in class AbstractGame
Parameters:
playerRole - DOCUMENT ME!
Returns:
DOCUMENT ME!

nextPlayer

public int nextPlayer()
DOCUMENT ME!

Returns:
DOCUMENT ME!

listLegalMoves

protected GameMove[] listLegalMoves()
DOCUMENT ME!

Specified by:
listLegalMoves in class AbstractGame
Returns:
DOCUMENT ME!

pushMove

protected boolean pushMove(GameMove move)
DOCUMENT ME!

Specified by:
pushMove in class AbstractGame
Parameters:
move - DOCUMENT ME!
Returns:
DOCUMENT ME!

popMove

protected boolean popMove()
DOCUMENT ME!

Specified by:
popMove in class AbstractGame
Returns:
DOCUMENT ME!

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Note: the cloned object will have a separate Random object assiciated with it, so that operations on the cloned object will not affect the random numbers of the original.

Specified by:
clone in interface GamePlay
Overrides:
clone in class AbstractGame
Returns:
DOCUMENT ME!
Throws:
java.lang.CloneNotSupportedException - DOCUMENT ME!
See Also:
AbstractGame.spawnChild(GameMove)

toString

public java.lang.String toString()
DOCUMENT ME!

Overrides:
toString in class AbstractGame
Returns:
DOCUMENT ME!