PokerAI.org Research @2007-2009

 

 

Free Hand History Database

Here is a sample program (source code) that produces the above chart (example). It gives an idea how one can make use of the Java software to read the database.

/*
  This code is released under GPL v3.
  This example calculates which cards (if any) flop more often than others.
*/

package pokerai.hhex.examples;

import pokerai.hhex.*;
import java.io.File;

public class FlopCardsDistribution {

  static long cards[] = new long[13];
  static int totalHands = 0;

  public static void main(String[] args) {
    String rootfolder = "C:\\hhdb\\";
    if (args.length > 0) rootfolder = args[0];
    if (!rootfolder.endsWith("\\")) rootfolder += "\\";
    // ---
    File dir = new File(rootfolder);
    String[] all = dir.list();
    // Scan for all files from site "Default",
    // Holdem NL, 6-seats, and aggregate stats for all found DBs
    for (int i = 0; i < all.length; i++)
       if (all[i].startsWith("pokerai.org.sample" +
           Consts.SITE_DEFAULT + "_" + Consts.HOLDEM_NL +
           "_6") && all[i].endsWith(".hhex")) {
              scan(rootfolder, all[i]);
           }
    // Printing results
    System.out.println("Number of hands parsed: " + (long)totalHands);
    for (byte i = 0; i < cards.length; i++) {
      System.out.println(Consts.printRank(i) + ": " + cards[i]);
    }
  }

  public static void scan(String rootfolder, String fullName) {
    HandManagerNIO hm = new HandManagerNIO();
    hm.init(rootfolder, fullName);
    hm.reset();
    while (hm.hasMoreHands()) {
      PokerHand hand = hm.nextPokerHand(); totalHands++;
      if (totalHands % 10000000 == 0) {
        System.out.println((long)totalHands + " hands read.");
      }
      byte[] boardCards = hand.getCommunityCardsBA();
      if (boardCards != null) {
        if (boardCards[0] != Consts.INVALID_CARD) {
          cards[Consts.getCardRank(boardCards[0])]++;
        }
        if (boardCards[1] != Consts.INVALID_CARD) {
          cards[Consts.getCardRank(boardCards[1])]++;
        }
        if (boardCards[2] != Consts.INVALID_CARD) {
          cards[Consts.getCardRank(boardCards[2])]++;
        }
      }
    }
    hm.closedb();
  }

}

We open the database here

Working with the database is as simple as working with Java Enumeration.

You just enumerate all hands in the DB and do whatever you want with them.

PokerHand is a wrapper class over each hands providing methods to read all information from the hand (e.g. community cards, stacks, bets, actions) plus a lot of utility classes - (isPlayerAllinPreflop, etc.).

       Academic Research        Public downloads        Examples         FAQ          Forums          About