c++ - Improving performance using pokerstove library -


i've started using pokerstove library (https://github.com/andrewprock/pokerstove) , managed perform basic hand / equity evaluations it. unfortunately, tried write bit more computationally expensive programs, ran massive performance issues couldn't figure out how deal with.

as example i've provided following program calculates average equity hand ace-6 of spades has against random hand:

#include <iostream> #include <vector> #include <pokerstove/penum/showdownenumerator.h>  int main() {  using namespace pokerstove; using namespace std;  cardset completedeck; completedeck.fill(); cout << "the whole deck has " << completedeck.size() << " cards" << endl;  carddistribution anytwo; anytwo.fill(completedeck, 2); cout << "there " << anytwo.size() << " 2 card combinations"  << endl;  carddistribution holecards; holecards.parse("as6s");  showdownenumerator showdown; vector<equityresult> result = showdown.calculateequity(     vector<carddistribution>{anytwo, holecards},     cardset(""),     pokerhandevaluator::alloc("h") );  double sharerandom = result.at(0).winshares + result.at(0).tieshares; double sharehand   = result.at(1).winshares + result.at(1).tieshares; double total       = sharerandom + sharehand;  cout << "a random hand has "  << sharerandom / total * 100  << " % equity (" << result.at(0).str() << ")" << endl; cout << "the hand as6s has "  << sharehand   / total * 100  << " % equity (" << result.at(1).str() << ")" << endl;  } 

once stops, outputs

the whole deck has 52 cards there 1326 2 card combinations random hand has 40.0942 % equity (804780676 36223609 0 0) hand as6s has 59.9058 % equity (1220344506 36223609 0 0) 

on machine (which admit isn't particularly fast) computation takes 4 minutes! since seems unreasonably long belief there has wrong (performance-wise) implementation.

hence, grateful if point out me i'm doing wrong / inefficient.

i suspect 1 can reduce number of random hands 1326 169 (due equivalence of suits), didn't find way implement behaviour.

any appreciated!

the short answer is: that's how fast goes.

a longer answer is, version general purpose evaluator capable of evaluating kind of game. not fancy caching results, precomputing large tables, using suit isomorphisms, or else.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -