I have some classes so far.
- Hand stores information like SB, BB, ante, collection of Players
- HandState inherits from class Hand. has members like phase {POSTING BLINDS, PREFLOP, FLOP, TURN, RIVER, SHOWDOWN }, pot. I consider every action in a poker hand as a handState. Players post ante (if any), Small blind and big blind posts blinds, the first player to act (UTG) calls the blind, the 2nd player (UTG+1) raises, etc...
- Player members: name, position, list of actions so far, stack, etc...
- Action members: type {FOLD,CALL, RAISE, RERAISE}, amount
The program receives as input the blinds, players, which player to act. Since the input I get is string (its a console program) I have to build the root handState.
After I have the root handState, I can build a gameTree where every node is a handState. eg.:
stacks = "1000,2000,2300,1400,230";
actions = "200";
playerToAct = 2;
BB = 400;
SB = 200;
function makeRoot()
{
stacks = makeArray(stacks)
for(i=0; i < stacks.size; i++)
{
player = new Player;
player.position = "UTG"
if (i > 0)
player.position += i;
if (i == stacks.size-2)
{
player.position = "SB";
player.bet(SB);
}
if (i == stacks.size-1)
{
player.position = "BB";
player.bet(BB);
}
}
}
My problem that Player and HandState has no connection. What if player has not enough chips to pay the BigBlind (230<400)? SB has enough chips, but if he bets 200, HandState's pot wont know about it? Should I keep track in both class?
//HandState
player.bet(200);
this.pot += 200;
//Player
bet(amount)
{
this.stack -= amount;
this.actions.push(new Action(amount, "BET"));
}
I hope there is some seasoned programmer with some poker knowledge to tell some opinion, critique my approach.