最近,我开始使用poker夫库(https://github.com/andrewprock/pokerstove),并设法使用它执行一些基本的手动/公平评估。不幸的是,当我试图编写一些计算成本更高的程序时,我遇到了大量的性能问题,无法解决这些问题。
作为一个例子,我提供了以下程序来计算黑桃的手Ace-6相对于完全随机的手的平均股本:
#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 are " << anyTwo.size() << " two 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;
}一旦它最终停止,它就输出。
The whole deck has 52 cards
There are 1326 two card combinations
A random hand has 40.0942 % equity (804780676 36223609 0 0)
The hand As6s has 59.9058 % equity (1220344506 36223609 0 0)在我的机器(我承认不是特别快)这个计算大约需要4分钟!因为这看起来不合理,所以我认为这个实现肯定有问题(性能上的)。
因此,如果有人能向我指出我做错了什么/效率低的事情,我将非常感激。
我怀疑一个人可以将随机的手从1326人减少到169人(因为西服的等价性),但我没有找到实现这种行为的方法。
任何帮助都是非常感谢的!
发布于 2015-08-26 15:10:14
简单的回答是:这就是它的速度。
一个更长的答案是,这个版本是一个通用的评估器,能够评估任何类型的游戏。它不会做任何花哨的事情,比如缓存结果、预计算大表、使用合适的同构或其他任何东西。
https://stackoverflow.com/questions/30558902
复制相似问题