poker
Class PlayerInfo

java.lang.Object
  extended by poker.PlayerInfo
All Implemented Interfaces:
java.io.Serializable

public class PlayerInfo
extends java.lang.Object
implements java.io.Serializable

Stores all of the information for a player during a poker game. Also contains references to a player's past history of games. This class is a little messy from evolution, and has some ugly hooks for the AI system.

Author:
Aaron Davidson
See Also:
Serialized Form

Constructor Summary
PlayerInfo(PlayerInfo pi, GameInfo gi)
          Copy constructor
PlayerInfo(java.lang.String playerName, GameInfo gi)
          Constructor.
 
Method Summary
 boolean active()
          Return true if the player is still active in the hand
 boolean allIn()
          Determine if a player is All-In
 double getAmountCallable()
           
 double getAmountInPot()
          Obtain the amount the player has put in the pot.
 double getAmountInPotThisRound()
          Obtain the amount the player has put in the pot.this round
 double getAmountRaiseable()
           
 double getAmountToCall()
          Determine the amount a player must pay to stay in the game
 double getBankRoll()
           
 double getBankRollInSmallBets()
           
 GameInfo getGameInfo()
          Get the context of the last action made by this player.
 int getLastAction()
          A single integer code for the last action made
 int getLastActionCode()
          A single integer code for the last action made
 double getLastAmountCalled()
          Get the amount called by this player during his last action
 double getLastBetsToCall()
          Obtain the amount of bets the player had to call during their last action.
 double getMaximumRisk()
          The maximum we can risk in the hand.
 java.lang.String getName()
          obtain the player's name
 double getNetGain()
           
 int getPosition()
          Deprecated. use getSeat() instead
 double getRaiseAmount(double amountToRaise)
          Return the amount the player can raise, given the desired amount to raise.
 Hand getRevealedHand()
          Obtain the hand revealed by this player
 int getSeat()
          Get our seat number in the GameInfo
 boolean hasActedThisRound()
          Check if a player has made at least one action this round
 boolean hasEnoughToCall()
           
 boolean hasEnoughToRaise()
           
 boolean inGame()
           
 boolean isButton()
           
 boolean isCommitted()
          Test if a player has volunatrily committed yet in this round
 double potOdds()
          Obtain the player's immediate pot odds
 double potRatio()
          The ratio of the money in the pot that belongs to the player
 void resetBankRoll()
           
 void save()
           
 void setBankRoll(double br)
           
 void setBankRollAndSave(double br)
           
 void setInGame(boolean value)
           
 void startNewGame()
          Start a new game with this player
 java.lang.String toString()
           
 void win(double amount)
          Give the player some money
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PlayerInfo

public PlayerInfo(java.lang.String playerName,
                  GameInfo gi)
Constructor.

Parameters:
playerName - the name of the player
gi - the game that the player is in

PlayerInfo

public PlayerInfo(PlayerInfo pi,
                  GameInfo gi)
Copy constructor

Parameters:
pi - the PlayerInfo to deep copy
gi - the new GameInfo to reference
Method Detail

save

public void save()

getNetGain

public double getNetGain()

setBankRollAndSave

public void setBankRollAndSave(double br)

setBankRoll

public void setBankRoll(double br)

resetBankRoll

public void resetBankRoll()

getBankRoll

public double getBankRoll()

getBankRollInSmallBets

public double getBankRollInSmallBets()

inGame

public boolean inGame()

setInGame

public void setInGame(boolean value)

getPosition

public int getPosition()
Deprecated. use getSeat() instead

Get our seat ID in the GameInfo


getSeat

public int getSeat()
Get our seat number in the GameInfo


startNewGame

public void startNewGame()
Start a new game with this player


getName

public java.lang.String getName()
obtain the player's name

Returns:
the name of this player

allIn

public boolean allIn()
Determine if a player is All-In

Returns:
true if all in, false otherwise

win

public void win(double amount)
Give the player some money

Parameters:
amount - the amount of money to give

getRevealedHand

public Hand getRevealedHand()
Obtain the hand revealed by this player

Returns:
the player's hand, or null if unrevealed

getAmountToCall

public double getAmountToCall()
Determine the amount a player must pay to stay in the game

Returns:
the amount needed to stay in.

isCommitted

public boolean isCommitted()
Test if a player has volunatrily committed yet in this round

Returns:
true if player is committed, false if not.

hasActedThisRound

public boolean hasActedThisRound()
Check if a player has made at least one action this round

Returns:
true if player has acted in this round

potOdds

public double potOdds()
Obtain the player's immediate pot odds

Returns:
the pot odds.

getLastAmountCalled

public double getLastAmountCalled()
Get the amount called by this player during his last action


getLastBetsToCall

public double getLastBetsToCall()
Obtain the amount of bets the player had to call during their last action.


getAmountInPot

public double getAmountInPot()
Obtain the amount the player has put in the pot.


getAmountInPotThisRound

public double getAmountInPotThisRound()
Obtain the amount the player has put in the pot.this round


potRatio

public double potRatio()
The ratio of the money in the pot that belongs to the player


getLastActionCode

public int getLastActionCode()
A single integer code for the last action made


getLastAction

public int getLastAction()
A single integer code for the last action made


getGameInfo

public GameInfo getGameInfo()
Get the context of the last action made by this player.


active

public boolean active()
Return true if the player is still active in the hand

Returns:
true if the player is still active

isButton

public boolean isButton()
Returns:
true if the player is currently the button

hasEnoughToCall

public boolean hasEnoughToCall()
Returns:
true if the player has enough money to call the current amount

hasEnoughToRaise

public boolean hasEnoughToRaise()
Returns:
true if the player has enough money to raise

getAmountRaiseable

public double getAmountRaiseable()
Returns:
the amount the player can raise

getAmountCallable

public double getAmountCallable()
Returns:
the amount the player can call

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
a string representation of the PlayerInfo

getMaximumRisk

public double getMaximumRisk()
The maximum we can risk in the hand. If we have all active players covered, then we can't lose more than the biggest bankroll. Otherwise, we can lose our entire bankroll.


getRaiseAmount

public double getRaiseAmount(double amountToRaise)
Return the amount the player can raise, given the desired amount to raise. Ensures a player can't raise more than they have.

Parameters:
amountToRaise - the desired amount to raise.
Returns:
the actual amount the player can raise