poker
Class GameInfo

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

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

Stores all of the info defining a single game of poker. This includes information of the game's players and the cards which are/were dealt. This class can be used to both archive a game's history and its state in progress. This class is a little messy, as it's been incrementally modified over many years.

Version:
1.1
Author:
Aaron Davidson
See Also:
Serialized Form

Field Summary
 java.lang.String LOG_DIR
           
static boolean USE_REVERSE_BLINDS
           
 
Constructor Summary
GameInfo()
          Default Constructor
 
Method Summary
 boolean activePlayer(int seat)
          Test if a player at a specific position is active in the game.
 void addWinner(java.lang.String name)
          Add a player to the list of winners
 int advanceCurrentPlayer()
          Advance the current player to the next active player in the game.
 void allInPass()
          the player is all-in, so passes on his action.
 int bigBlind()
          Big Blind the current player
 int call()
          Call the current player
 boolean canRaise()
          Determine if the current player is allowed to raise.
 void clearSeat(int seat)
           
 void flop(Card c1, Card c2, Card c3)
          Proceed to stage FLOP
 boolean fold()
          Fold the current player
 void gameOver()
          Report the end of the game and log player and game history.
 int getAmountToCall(int pos)
          Get the amount a player must call to stay in
 int getBetAmount()
          Obtain the total amount players must have in the pot to stay in
 java.util.ArrayList getBetList()
          A list containing the size of each bet/raise made through the hand.
 int getBetSize()
          Get the current size of the bet.
 double getBetsToCall(int pos)
          Get the number of bets a player must call to stay in
 int getBigBet()
          Get the size of a big bet (usually double the big-blind).
 int getBigBlindSeat()
           
 int getBigBlindSize()
          Get the size of a big blind.
 Hand getBoard()
          obtain a Hand containing the board cards.
 Card getBoardCard(int i)
          Obtain the nth card on the table
 int getButton()
           
 PlayerInfo getCurrentPlayerInfo()
           
 java.lang.String getCurrentPlayerName()
           
 int getCurrentPlayerPosition()
           
 int getEligiblePot(int playerID)
          Get the amount in the pot, a player is eligble for
 int getFirstPlayerAfterButton()
          Find the seat of the first player in the game after the button.
 PlayerInfo getFirstPlayerWithMostIn()
          Find the first player who has the most invested in the pot.
 int getHandRank(Card c1, Card c2)
          Look up a the rank of a hand against the current board
 int[][] getHandRanks()
          Returns a 52x52 array of hand rank values for every hand against the current board;
 int getID()
           
 Pot getMainPot()
          Get the main Pot object.
 int getMinRaise()
          Get the minimum raise amount.
 int getNumActivePlayers()
           
 int getNumActivePlayersNotAllIn()
          Get the number of players in the hand that still have chips
 int getNumberOfAllInPlayers()
          Get the number of players in the hand who are all-in.
 int getNumPlayers()
           
 int getNumPlayersWithChips()
          Get the number of players with chips left
 int getNumRaises()
           
 int getNumSeats()
          The number of seats at the table.
 int getNumToAct()
          Get the number of players left to act in the betting round.
 int getNumWinners()
           
 PlayerInfo getPlayerInfo(int i)
          Get a PlayerInfo by seat number
 PlayerInfo getPlayerInfo(java.lang.String name)
          Given a name, obtain the PlayerInfo object for that player
 java.lang.String getPlayerName(int p)
          Get the player's name from a position
 int getPlayerSeat(java.lang.String name)
          From a name, find out a player's position
 java.util.ArrayList getPlayersInPot(int amountIn)
          Get the number of players eligible to win the pot where the stakes for the pot are below the given amount.
 int getPot()
          Get the total size of the pot, including all side pots
 int getRaiseAmount(int amountToRaise)
          Return the amount the current player can raise, given the desired amount to raise.
 Reporter getReporter()
          Get the Reporter used for all game debug output
 java.lang.String getSequence()
          Get the entire betting sequence of the hand.
 int getSmallBet()
          Get the size of a small bet (the big-blind).
 int getSmallBlindSeat()
           
 int getSmallBlindSize()
          Get the size of a small blind.
 int getStage()
           
 int getUnacted()
          Obtain the number of opponents who have not yet acted in this betting round.
 java.lang.String getWinners()
           
 boolean inGame(int seat)
          Test if a player is in this game or not.
 boolean isFlop()
          Get if the game is in the flop stage
 boolean isGameOver()
          Check if the hand is over or not
 boolean isNoCapHU()
          Get option to have no cap once it is heads-up
 boolean isNoLimit()
          Determine if the game is no-limit
 boolean isPostFlop()
          Get if the game is in a post-flop stage
 boolean isPreFlop()
          Get if the game is in the pre-flop stage
 boolean isRiver()
          Get if the game is in the river stage
 boolean isSimulation()
          Determine if the game is in simulation mode.
 boolean isTurn()
          Get if the game is in the turn stage
 boolean isZipMode()
          Zip mode is a flag for bots to think at a reduced capacity where speed of play is valued over quality of decisions.
 PlayerInfo loadPlayerInfo(java.lang.String name)
          Adds a new player to the game.
 void logGame()
          Saves all bankrolls at the time of invokation.
 void moveButtonBack()
          move the button back by one position.
 void muck(int seat)
          Inform game info that a player has mucked.
 int nextActivePlayer(int seat)
          Given a position, returns the position of the next active player
 int nextPlayer(int pos)
          Get the seat of the next player after the given seat
 void payPot(int amount, PlayerInfo pi)
          Pay an amount to the pot, from the given player
 boolean playerCommitted(int pos)
          Test if a player has committed in the current betting round.
 int previousPlayer(int pos)
          Get the seat of the previous player after the given seat
 int raise(int amountToRaise)
          Raise the current player
 void removeAllPlayers()
          Remove all the players from the game
 boolean removePlayer(java.lang.String name)
          Remove a player from the game.
 int removeUncalledChips()
          Remove all uncalled chips from the pot
 void revealHand(int n, Card c1, Card c2)
          Reveal a players hand in a showdown.
 void revealHand(java.lang.String name, Card c1, Card c2)
          Reveal a players hand in a showdown.
 void river(Card c)
          Proceed to stage RIVER
 boolean seatEmpty(int seat)
          Test if a player is in this seat or not.
 void setBigBlindSeat(int i)
          Set the position of the big blind seat.
 void setButton(int i)
          Set the Button.
 void setCurrentPlayerPosition(int cp)
          Set the current player position
 void setLimits(int smallBlind, int smallBet, int bigBet)
          Set the betting limits for the game.
 void setLogDir(java.lang.String s)
          Set the Log Directory used by all players for keeping logs
 void setNoCapHU(boolean val)
          Set option to have no cap once it is heads-up
 void setNoLimit(boolean val)
           
 boolean setPlayer(java.lang.String name, int seat)
          Insert a new player into the game.
 void setPot(int p)
          Set the pot size
 void setSimulation(boolean val)
          Set simulation mode on or off
 void setSmallBlindSeat(int i)
          Set the position of the small blind seat.
 void setZipMode(boolean val)
          Zip mode is a flag for bots to think at a reduced capacity, where speed of play is valued over quality of decisions.
 int smallBlind()
          Small Blind the current player.
 void startNewGame()
          Before a new game is played, this should always be called.
 void startNewGame(int id)
          Before a new game is played, this should always be called.
 void turn(Card c)
          Proceed to stage TURN
 boolean useReverseBlinds()
          Find out if we should use reverse blinds or not.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USE_REVERSE_BLINDS

public static boolean USE_REVERSE_BLINDS

LOG_DIR

public java.lang.String LOG_DIR
Constructor Detail

GameInfo

public GameInfo()
Default Constructor

Method Detail

getReporter

public Reporter getReporter()
Get the Reporter used for all game debug output


setLogDir

public void setLogDir(java.lang.String s)
Set the Log Directory used by all players for keeping logs

Parameters:
s - a directory path name

setNoLimit

public void setNoLimit(boolean val)

isNoLimit

public boolean isNoLimit()
Determine if the game is no-limit

Returns:
true if the game is no-limit

isSimulation

public boolean isSimulation()
Determine if the game is in simulation mode. In simulation mode, players may choose to play faster, using cruder approximations, and should avoid all use of disk.

Returns:
true if the game is in simulation mode.

setSimulation

public void setSimulation(boolean val)
Set simulation mode on or off


isZipMode

public boolean isZipMode()
Zip mode is a flag for bots to think at a reduced capacity where speed of play is valued over quality of decisions.


setZipMode

public void setZipMode(boolean val)
Zip mode is a flag for bots to think at a reduced capacity, where speed of play is valued over quality of decisions.


isNoCapHU

public boolean isNoCapHU()
Get option to have no cap once it is heads-up


setNoCapHU

public void setNoCapHU(boolean val)
Set option to have no cap once it is heads-up


inGame

public boolean inGame(int seat)
Test if a player is in this game or not.

Parameters:
seat - the seat of the player in question
Returns:
true if the player is in the game, false otherwise

seatEmpty

public boolean seatEmpty(int seat)
Test if a player is in this seat or not.

Parameters:
seat - the seat in question
Returns:
true if the seat is empty

startNewGame

public void startNewGame()
Before a new game is played, this should always be called. Initializes the game state data.


startNewGame

public void startNewGame(int id)
Before a new game is played, this should always be called. Initializes the game state data.


loadPlayerInfo

public PlayerInfo loadPlayerInfo(java.lang.String name)
Adds a new player to the game.

Parameters:
name - the name of the new player
Returns:
true if added, false if not added

setPlayer

public boolean setPlayer(java.lang.String name,
                         int seat)
Insert a new player into the game.

Parameters:
name - the name of the new player
seat - the position to insert at (0..numPlayers)
Returns:
true if added, false if not added

clearSeat

public void clearSeat(int seat)

removePlayer

public boolean removePlayer(java.lang.String name)
Remove a player from the game.

Parameters:
name - the name of the player to remove
Returns:
true if removed, false if not.

removeAllPlayers

public void removeAllPlayers()
Remove all the players from the game


getButton

public int getButton()
Returns:
the button position

getSmallBlindSeat

public int getSmallBlindSeat()
Returns:
seat where small blind should be posted from (including dead small blind)

getBigBlindSeat

public int getBigBlindSeat()
Returns:
seat where big blind should be posted from

setButton

public void setButton(int i)
Set the Button.

Parameters:
i - position to become button

setSmallBlindSeat

public void setSmallBlindSeat(int i)
Set the position of the small blind seat.

Parameters:
i - position to become the small blind (maybe dead)

setBigBlindSeat

public void setBigBlindSeat(int i)
Set the position of the big blind seat.

Parameters:
i - position to become big blind (maybe dead)

getSmallBlindSize

public int getSmallBlindSize()
Get the size of a small blind.

Returns:
the size of a small blind.

getBigBlindSize

public int getBigBlindSize()
Get the size of a big blind.

Returns:
the size of a big blind.

setLimits

public void setLimits(int smallBlind,
                      int smallBet,
                      int bigBet)
Set the betting limits for the game.

Parameters:
smallBlind - the size of the small blind
smallBet - the size of the small bet / big blind
bigBet - the size of the big bet

getSmallBet

public int getSmallBet()
Get the size of a small bet (the big-blind). This is the size of a bet on the pre-flop and flop betting rounds.

Returns:
the small bet size

getBigBet

public int getBigBet()
Get the size of a big bet (usually double the big-blind). This is the size of a bet on the turn and river betting rounds.

Returns:
the big bet size

getStage

public int getStage()
Returns:
the current stage {PREFLOP,FLOP,TURN,RIVER}

isPreFlop

public boolean isPreFlop()
Get if the game is in the pre-flop stage

Returns:
true if the game is in the pre-flop stage

isFlop

public boolean isFlop()
Get if the game is in the flop stage

Returns:
true if the game is in the flop stage

isTurn

public boolean isTurn()
Get if the game is in the turn stage

Returns:
true if the game is in the turn stage

isRiver

public boolean isRiver()
Get if the game is in the river stage

Returns:
true if the game is in the river stage

isPostFlop

public boolean isPostFlop()
Get if the game is in a post-flop stage

Returns:
true if the game is in a post-flop stage

getPot

public int getPot()
Get the total size of the pot, including all side pots

Returns:
the total pot size

setPot

public void setPot(int p)
Set the pot size


getID

public int getID()
Returns:
the game ID

getNumPlayers

public int getNumPlayers()
Returns:
the number of players in the game

getNumActivePlayers

public int getNumActivePlayers()
Returns:
the number of players still in the game (not folded)

getNumRaises

public int getNumRaises()
Returns:
the number of raises made during this stage (including Big Blind)

getBoardCard

public Card getBoardCard(int i)
Obtain the nth card on the table

Parameters:
i - the card desired {0..4}
Returns:
the card at position i

getBoard

public Hand getBoard()
obtain a Hand containing the board cards.

Returns:
the board cards.

getPlayerSeat

public int getPlayerSeat(java.lang.String name)
From a name, find out a player's position

Parameters:
name - the player's name
Returns:
the player's position or -1 if not found

getPlayerName

public java.lang.String getPlayerName(int p)
Get the player's name from a position

Parameters:
p - the position
Returns:
the name

getCurrentPlayerName

public java.lang.String getCurrentPlayerName()
Returns:
the name of the current player

getPlayerInfo

public PlayerInfo getPlayerInfo(int i)
Get a PlayerInfo by seat number

Returns:
the player in seat i or null if empty.

getPlayerInfo

public PlayerInfo getPlayerInfo(java.lang.String name)
Given a name, obtain the PlayerInfo object for that player

Parameters:
name - the player's name
Returns:
the Player's Information

getCurrentPlayerInfo

public PlayerInfo getCurrentPlayerInfo()
Returns:
the PlayerInfo for the current player

getCurrentPlayerPosition

public int getCurrentPlayerPosition()
Returns:
the position of the current player

setCurrentPlayerPosition

public void setCurrentPlayerPosition(int cp)
Set the current player position

Parameters:
cp - the position to make current.

advanceCurrentPlayer

public int advanceCurrentPlayer()
Advance the current player to the next active player in the game.

Returns:
returns the position of the new current player

nextPlayer

public int nextPlayer(int pos)
Get the seat of the next player after the given seat

Parameters:
pos - the specified seat
Returns:
the next player seat after the specified seat

previousPlayer

public int previousPlayer(int pos)
Get the seat of the previous player after the given seat

Parameters:
pos - the specified seat
Returns:
the next player seat before the specified seat

nextActivePlayer

public int nextActivePlayer(int seat)
Given a position, returns the position of the next active player

Parameters:
seat - specified position
Returns:
the next active position after the specified position

activePlayer

public boolean activePlayer(int seat)
Test if a player at a specific position is active in the game.

Parameters:
seat - the position to check.
Returns:
true if the player is active, false if not

getMinRaise

public int getMinRaise()
Get the minimum raise amount. This is fixed in limit, but in no-limit it is the big-blind size if there has been no betting, otherwise it is the size of the last raise made.

Returns:
the minimum legal raise size

allInPass

public void allInPass()
the player is all-in, so passes on his action.


fold

public boolean fold()
Fold the current player

Returns:
true if game is over.

muck

public void muck(int seat)
Inform game info that a player has mucked.

Parameters:
seat - the seat to muck

smallBlind

public int smallBlind()
Small Blind the current player.


bigBlind

public int bigBlind()
Big Blind the current player


call

public int call()
Call the current player

Returns:
the amount called

getRaiseAmount

public int getRaiseAmount(int amountToRaise)
Return the amount the current 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

raise

public int raise(int amountToRaise)
Raise the current player

Parameters:
amountToRaise - the amount being raised
Returns:
the amount the player bet or raised

getBetList

public java.util.ArrayList getBetList()
A list containing the size of each bet/raise made through the hand.


flop

public void flop(Card c1,
                 Card c2,
                 Card c3)
Proceed to stage FLOP

Parameters:
c1 - table card 1
c2 - table card 2
c3 - table card 3

turn

public void turn(Card c)
Proceed to stage TURN

Parameters:
c - table card 4

river

public void river(Card c)
Proceed to stage RIVER

Parameters:
c - table card 4

gameOver

public void gameOver()
Report the end of the game and log player and game history. Should only be called once at the end of a game


isGameOver

public boolean isGameOver()
Check if the hand is over or not

Returns:
true if the hand is over

logGame

public void logGame()
Saves all bankrolls at the time of invokation.


revealHand

public void revealHand(java.lang.String name,
                       Card c1,
                       Card c2)
Reveal a players hand in a showdown.

Parameters:
name - the name of the player
c1 - the first card
c2 - the second card

revealHand

public void revealHand(int n,
                       Card c1,
                       Card c2)
Reveal a players hand in a showdown.

Parameters:
n - the position of the player
c1 - the first card
c2 - the second card

addWinner

public void addWinner(java.lang.String name)
Add a player to the list of winners

Parameters:
name - the name of the player.

getWinners

public java.lang.String getWinners()
Returns:
A string containing the names of the game's winners.

getNumWinners

public int getNumWinners()
Returns:
The number of winners for this hand

getUnacted

public int getUnacted()
Obtain the number of opponents who have not yet acted in this betting round.

Returns:
the number of unacted players

getFirstPlayerAfterButton

public int getFirstPlayerAfterButton()
Find the seat of the first player in the game after the button.

Returns:
seat of first player in game (i.e. not all-in at the start of the hand) after button.

getAmountToCall

public int getAmountToCall(int pos)
Get the amount a player must call to stay in

Parameters:
pos - the position of the player
Returns:
the amount to call

getBetsToCall

public double getBetsToCall(int pos)
Get the number of bets a player must call to stay in

Parameters:
pos - the position of the player
Returns:
the number of bets to call

playerCommitted

public boolean playerCommitted(int pos)
Test if a player has committed in the current betting round.

Parameters:
pos - the position of the player
Returns:
true if the player has voluntarily committed in the round, false otherwise.

getBetAmount

public int getBetAmount()
Obtain the total amount players must have in the pot to stay in

Returns:
the total bet amount

getBetSize

public int getBetSize()
Get the current size of the bet.

Returns:
the size of the bet for the current stage.

getHandRanks

public int[][] getHandRanks()
Returns a 52x52 array of hand rank values for every hand against the current board;


getHandRank

public int getHandRank(Card c1,
                       Card c2)
Look up a the rank of a hand against the current board


getNumToAct

public int getNumToAct()
Get the number of players left to act in the betting round.

Returns:
the number of players to act

getSequence

public java.lang.String getSequence()
Get the entire betting sequence of the hand. ex: sBfck/kbrc/kk/bc/

Returns:
a string with the betting sequence of the hand

getNumSeats

public final int getNumSeats()
The number of seats at the table.

Returns:
the number of seats at the table.

useReverseBlinds

public boolean useReverseBlinds()
Find out if we should use reverse blinds or not.


moveButtonBack

public void moveButtonBack()
move the button back by one position.


canRaise

public boolean canRaise()
Determine if the current player is allowed to raise.

Returns:
true if the current player is allowed to raise

getFirstPlayerWithMostIn

public PlayerInfo getFirstPlayerWithMostIn()
Find the first player who has the most invested in the pot. Starts with the current player.

Returns:
the first player found with the most invested in the pot.

getNumberOfAllInPlayers

public int getNumberOfAllInPlayers()
Get the number of players in the hand who are all-in.

Returns:
the number of players who are all-in

getNumActivePlayersNotAllIn

public int getNumActivePlayersNotAllIn()
Get the number of players in the hand that still have chips

Returns:
the number of players that still have chips

getPlayersInPot

public java.util.ArrayList getPlayersInPot(int amountIn)
Get the number of players eligible to win the pot where the stakes for the pot are below the given amount. Used by dealer for showdowns with multiple pots.

Parameters:
amountIn - the stakes for the pots to count
Returns:
a list of players eligible to win the given pot(s).

getEligiblePot

public int getEligiblePot(int playerID)
Get the amount in the pot, a player is eligble for

Parameters:
playerID - the player ID
Returns:
the amount in the pot matching the amountIn

getMainPot

public Pot getMainPot()
Get the main Pot object. The Pot is a linked list of all pots

Returns:
the main pot

payPot

public void payPot(int amount,
                   PlayerInfo pi)
Pay an amount to the pot, from the given player

Parameters:
amount - the amount to put in the pot
pi - the player who is paying

removeUncalledChips

public int removeUncalledChips()
Remove all uncalled chips from the pot

Returns:
the amount removed from the pot.

getNumPlayersWithChips

public int getNumPlayersWithChips()
Get the number of players with chips left

Returns:
the number of players with chips left