Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Designing a hand history class for Texas Hold'em in Java

Tags:

java

poker

I am trying to come up with a Java hand history class for Texas Hold'em and wanted to bounce an idea off here.

Requirements are that every action is stored and there is an efficient way to traverse each HandHistory object (which would represent a single played hand) to match common 'lines' like the standard continuation bet (i.e. the preflop raiser who was in late position preflop and probably is in position postflop is checked to and then makes a 75%ish pot bet).

Ignore for the moment that the definitions for each of the lines is fuzzy at best. As a first stab, I was thinking of organizing it like so:

public class HandHistory {
    private Integer handnumber;
    //in case we saw things at showdown, put them here
    private HashMap<Player,String> playerHands; 
    private String flopCards;
    private String turnCard;
    private String riverCard;
    private HashMap<BetRound,LinkedHashMap<Integer,ArrayList<PlayerAction>>> actions;
}

So, for each betround we store a linked hashmap whose keys are integers that are the offsets from first position to act for that betround, so preflop UTG is 0.

We generate the actions in position order already, so use a linked hashmap so we can iterate nicely later and skip over positions that are sitting out,etc.

Each arraylist will contain the actions that that position had in that betround. Most of the time this array will have one element, but in cases like, limps and then calls, it will have two.

Can anyone see a better data structure to use for this?

like image 651
rndapology Avatar asked Nov 14 '22 21:11

rndapology


1 Answers

small change, since holdem has a fixed number of betting rounds, maybe

private HashMap<BetRound,LinkedHashMap<Integer,ArrayList<PlayerAction>>> actions;

could just be:

private LinkedHashMap<Integer,ArrayList<PlayerAction>>[] actions= new ... ;

also, here's a couple of books that may be of interest:

http://www.amazon.com/Poker-strategy-Winning-game-theory/dp/0399506691

http://www.amazon.com/Mathematics-Poker-Bill-Chen/dp/1886070253

like image 151
Ray Tayek Avatar answered Dec 18 '22 04:12

Ray Tayek