Skip to content

C++ Library to Evaluate Handranges for Pokerhands

License

Notifications You must be signed in to change notification settings

pandaant/libecalc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Libecalc

Libecalc lets you compare Poker Hands and Ranges.

Requirements

  • UnitTest++ for tests (expects headers and lib to be in /usr/{lib,include})

Build

$ git clone --recursive https://github.com/pandaant/libecalc

# compile lib
$ cd libecalc/dep/libpoker
$ make all
# build documentation (requires doxygen)
$ make doc

# build and run tests
$ cd test 
$ make all run

A compiled version of the doxygen documentation can be found here

Usage

Initialization

using namespace ecalc;
using namespace poker;

// supply path to handranks file. 
Handranks handranks("handranks.dat");
// initialize ecalc with handranks and seed for rng
ECalc calc(&handranks, 0);

Evaluate Hand vs Random

// supply vector of cards that is present on the board already (preflop)
cards board, dead;

// Create a handlist with a single specific hand.
Handlist* hand = new SingleHandlist(Hand("AhAs"));

// evaluate hand against random sampled hands
result_collection res = calc.evaluate_vs_random(
    hand,  		// handlist
    1, 			// number of random players to check against
    board, 		// the boardcards
    dead, 		// list of deadcards
    NB_SAMPLES	// number of samples to use. the higher the better
);

// res stores the percentage of win,tie and loss in a vector for each hand
cout << "pwin: " << res[0].pwin_tie() << endl; // 0.85204
delete hand;

Evaluate 2 specific Hands with board cards

cards dead;
cards board({(card)Card("Jh").card(), (card)Card("Qd").card(),
             (card)Card("Kh").card()});

Handlist::collection_t hands({new SingleHandlist(Hand("AcKd")),
                              new SingleHandlist(Hand("JsTs"))});

result_collection res = calc.evaluate(hands, board, dead, NB_SAMPLES);
// res[0].pwin_tie() => 0.66313
// res[1].pwin_tie() => 0.33687

for( unsigned i = 0; i < hands.size(); ++i)
    delete hands[i];

Evaluate Hand ranges with board cards

cards dead;
cards board({(card)Card("Jh").card(), (card)Card("Qd").card(),
             (card)Card("Kh").card()});

Handlist::collection_t hands({
	new SingleHandlist(Hand("AcKd")),
	new ArrayHandlist({Hand("AhAs"), Hand("KhKs"), Hand("QcQd")})
});

result_collection res = calc.evaluate(hands, board, dead, NB_SAMPLES);

for( unsigned i = 0; i < hands.size(); ++i)
    delete hands[i];

About

C++ Library to Evaluate Handranges for Pokerhands

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published