我正在使用此处为nodejs找到的此手评估器:
https://github.com/chenosaurus/poker-evaluator
效果很好,在评估手牌方面非常快。但是,我想用它来编写一个脚本来计算赢得对手的胜率。
例如,两名选手有两手牌:[Ac,8c] Vs [9d,9h]等。
我已尝试在所有可能的纸牌上循环,例如:
var cards = [
"2c","3c","4c","5c","6c","7c","8c","9c","Tc","Jc","Qc","Kc","Ac",
"2d","3d","4d","5d","6d","7d","8d","9d","Td","Jd","Qd","Kd","Ad",
"2h","3h","4h","5h","6h","7h","8h","9h","Th","Jh","Qh","Kh","Ah",
"2s","3s","4s","5s","6s","7s","8s","9s","Ts","Js","Qs","Ks","As",
];
var hand = ["As", "Ks"];
var trials = 0;
for(i=0;i<cards.length;i++) {
for(j=i+1;j<cards.length;j++) {
for(k=j+1;k<cards.length;k++) {
for(l=k+1;l<cards.length;l++) {
for(m=l+1;m<cards.length;m++) {
trials++;
var nh = hand.slice();
nh.push(cards[i]);
nh.push(cards[j]);
nh.push(cards[k]);
nh.push(cards[l]);
nh.push(cards[m]);
PokerEvaluator.evalHand(nh);
}
}
}
}
}
显然这还没有完成(它没有检查手的等级或比较它),但这是我知道评估双手所有可能的板组合的唯一方法。
尽管该算法能够每秒评估数百万手牌,但速度非常慢。有没有更好的方法来检查两只手,而不是在所有可能的评估中使用for循环?答案 0 :(得分:2)
最简单的方法是使用蒙特卡洛。基本上,您只是随机生成了几千手牌,然后计算获胜次数并除以生成的总手数。您玩的手越多,您的结果就越准确。