blackjackanalyst.observer
Class WinLossPlayerObserver

java.lang.Object
  extended by blackjackanalyst.observer.WinLossPlayerObserver
All Implemented Interfaces:
PlayerObserver

public class WinLossPlayerObserver
extends java.lang.Object
implements PlayerObserver

A player observer that records the number of wins and losses a player has had.

Author:
Michael Parker

Constructor Summary
WinLossPlayerObserver()
          Creates a new player observer that gathers statistics.
 
Method Summary
 int getLossStreak()
          Returns the longest loss streak for this player.
 int getNetGain()
          Returns the combined net winnings of this player; a negative number returned indicates a winning house.
 int getNumBlackjacks()
          Returns the number of times the player has received a blackjack.
 int getNumLosses()
          Returns the number of times the player has lost.
 int getNumPushes()
          Returns the number of times the player pushed.
 int getNumWins()
          Returns the number of times the player has won, not including blackjacks.
 int getWinStreak()
          Returns the longest win streak for this player, which may include blackjacks.
 void playerBets(int bet_amount, int bankroll)
          This method is invoked when the player makes a bet.
 void playerBlackjack(PlayerHand player_hand, int amount_won, int new_bankroll)
          This method is invoked when the observed player gets a blackjack.
 void playerBusts(PlayerHand player_hand, int amount_lost, int new_bankroll)
          This method is invoked when the player busts.
 void playerDealt(PlayerHand player_hand)
          This method is invoked when the player is dealt a new hand.
 void playerDoublesDown(Card dealt_card, PlayerHand new_hand)
          This method is invoked when the player doubles down and is drawn a final card.
 void playerDraws(Card dealt_card, PlayerHand new_hand)
          This method is invoked when the player hits and is drawn a new card.
 void playerInsures(int bet_amount, int bankroll)
          This method is invoked when the player makes his insurance bet.
 void playerJoins(Table t)
          This method is invoked when the player joins a table.
 void playerLeaves(Table t)
          This method is invoked when the player leaves the table it had previously joined.
 void playerLoses(PlayerHand player_hand, int amount_lost, int new_bankroll)
          This method is invoked when the observed player loses.
 void playerLosesInsurance(int amount_lost, int new_bankroll)
          This method is invoked when the observed player loses his insurance bet.
 void playerPush(PlayerHand player_hand, int held_bankroll)
          This method is invoked when the observed player ties the dealer, or pushes.
 void playerSplits(PlayerHand player_hand)
          This method is invoked when the player splits the hand.
 void playerStands(PlayerHand player_hand)
          This method is invoked when the player stands.
 void playerWins(PlayerHand player_hand, int amount_won, int new_bankroll)
          This method is invoked when the observed player wins, but does not get blackjack.
 void playerWinsInsurance(int amount_won, int new_bankroll)
          This method is invoked when the observed player wins his insurance bet.
 void reset()
          Resets the statistics recorded by this observer.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WinLossPlayerObserver

public WinLossPlayerObserver()
Creates a new player observer that gathers statistics.

Method Detail

reset

public void reset()
Resets the statistics recorded by this observer.


playerJoins

public void playerJoins(Table t)
Description copied from interface: PlayerObserver
This method is invoked when the player joins a table.

Specified by:
playerJoins in interface PlayerObserver
Parameters:
t - the table the player has joined

playerLeaves

public void playerLeaves(Table t)
Description copied from interface: PlayerObserver
This method is invoked when the player leaves the table it had previously joined.

Specified by:
playerLeaves in interface PlayerObserver
Parameters:
t - the table the player has left

playerBets

public void playerBets(int bet_amount,
                       int bankroll)
Description copied from interface: PlayerObserver
This method is invoked when the player makes a bet.

Specified by:
playerBets in interface PlayerObserver
Parameters:
bet_amount - the amount the player bet
bankroll - the bankroll of the player, which includes the amount bet

playerInsures

public void playerInsures(int bet_amount,
                          int bankroll)
Description copied from interface: PlayerObserver
This method is invoked when the player makes his insurance bet.

Specified by:
playerInsures in interface PlayerObserver
Parameters:
bet_amount - the amount the player insures
bankroll - the bankroll of the player, which includes the amount bet

playerDealt

public void playerDealt(PlayerHand player_hand)
Description copied from interface: PlayerObserver
This method is invoked when the player is dealt a new hand.

Specified by:
playerDealt in interface PlayerObserver
Parameters:
player_hand - the hand dealt to the player

playerDraws

public void playerDraws(Card dealt_card,
                        PlayerHand new_hand)
Description copied from interface: PlayerObserver
This method is invoked when the player hits and is drawn a new card.

Specified by:
playerDraws in interface PlayerObserver
Parameters:
dealt_card - the new card the player draws
new_hand - the player hand including the drawn card

playerStands

public void playerStands(PlayerHand player_hand)
Description copied from interface: PlayerObserver
This method is invoked when the player stands.

Specified by:
playerStands in interface PlayerObserver
Parameters:
player_hand - the player hand stood with

playerBusts

public void playerBusts(PlayerHand player_hand,
                        int amount_lost,
                        int new_bankroll)
Description copied from interface: PlayerObserver
This method is invoked when the player busts.

Specified by:
playerBusts in interface PlayerObserver
Parameters:
player_hand - the player hand busted with
amount_lost - the amount the player lost
new_bankroll - the new bankroll of the player, after subtracting the loss

playerSplits

public void playerSplits(PlayerHand player_hand)
Description copied from interface: PlayerObserver
This method is invoked when the player splits the hand.

Specified by:
playerSplits in interface PlayerObserver
Parameters:
player_hand - the player hand that was split

playerDoublesDown

public void playerDoublesDown(Card dealt_card,
                              PlayerHand new_hand)
Description copied from interface: PlayerObserver
This method is invoked when the player doubles down and is drawn a final card.

Specified by:
playerDoublesDown in interface PlayerObserver
Parameters:
dealt_card - the final card the player draws
new_hand - the player hand including the drawn card

playerWins

public void playerWins(PlayerHand player_hand,
                       int amount_won,
                       int new_bankroll)
Description copied from interface: PlayerObserver
This method is invoked when the observed player wins, but does not get blackjack.

Specified by:
playerWins in interface PlayerObserver
Parameters:
player_hand - the hand the player won on
amount_won - the amount the player won
new_bankroll - the new bankroll of the player, after adding the winning

playerLoses

public void playerLoses(PlayerHand player_hand,
                        int amount_lost,
                        int new_bankroll)
Description copied from interface: PlayerObserver
This method is invoked when the observed player loses.

Specified by:
playerLoses in interface PlayerObserver
Parameters:
player_hand - the hand the player lost on
amount_lost - the amount the player lost
new_bankroll - the new bankroll of the player, after subtracting the loss

playerBlackjack

public void playerBlackjack(PlayerHand player_hand,
                            int amount_won,
                            int new_bankroll)
Description copied from interface: PlayerObserver
This method is invoked when the observed player gets a blackjack.

Specified by:
playerBlackjack in interface PlayerObserver
Parameters:
player_hand - the hand the player received blackjack on
amount_won - the amount the player won on blackjack
new_bankroll - the new bankroll of the player, after adding the winning

playerPush

public void playerPush(PlayerHand player_hand,
                       int held_bankroll)
Description copied from interface: PlayerObserver
This method is invoked when the observed player ties the dealer, or pushes.

Specified by:
playerPush in interface PlayerObserver
Parameters:
player_hand - the hand the player pushed on
held_bankroll - the unchanged bankroll of the player

playerWinsInsurance

public void playerWinsInsurance(int amount_won,
                                int new_bankroll)
Description copied from interface: PlayerObserver
This method is invoked when the observed player wins his insurance bet.

Specified by:
playerWinsInsurance in interface PlayerObserver
Parameters:
amount_won - the amount the player won
new_bankroll - the new bankroll of the player, after adding the winning

playerLosesInsurance

public void playerLosesInsurance(int amount_lost,
                                 int new_bankroll)
Description copied from interface: PlayerObserver
This method is invoked when the observed player loses his insurance bet.

Specified by:
playerLosesInsurance in interface PlayerObserver
Parameters:
amount_lost - the amount the player lost
new_bankroll - the new bankroll of the player, after subtracting the loss

getNumWins

public int getNumWins()
Returns the number of times the player has won, not including blackjacks.

Returns:
the number of player wins

getNumLosses

public int getNumLosses()
Returns the number of times the player has lost.

Returns:
the number of player losses

getNumBlackjacks

public int getNumBlackjacks()
Returns the number of times the player has received a blackjack.

Returns:
the number of player blackjacks

getNumPushes

public int getNumPushes()
Returns the number of times the player pushed.

Returns:
the number of player pushes.

getWinStreak

public int getWinStreak()
Returns the longest win streak for this player, which may include blackjacks. A winning streak is broken any time the player pushes or loses.

Returns:
the longest player win streak

getLossStreak

public int getLossStreak()
Returns the longest loss streak for this player. A losing streak is broken any time the player pushes or wins.

Returns:
the longest player loss streak

getNetGain

public int getNetGain()
Returns the combined net winnings of this player; a negative number returned indicates a winning house.

Returns:
the net winnings of this player

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object