狂野的打分给扑克手打分

时间:2020-03-05 18:50:02  来源:igfitidea点击:

我正在寻找代码或者算法的描述,以便在局末平局时确定扑克手的得分。我想要不受许可费,GPL,专利等约束的代码。

我知道几种解决此问题的方法,但是如果某个地方已经有代码,我宁愿不编写代码。因此,如果答案仅限于指向实际工作代码或者详细算法说明的链接,我将不胜感激。

(我并不是要任何人"为我做功课。"我可以自己编写代码,因此不需要伪代码和实现建议。我只是不想浪费时间来解决一个已经解决的问题。)

解决方案

回答

我想是因为我们说过,我们特别不想要想法,而只是想要一个可行的解决方案。

我认为,通常的想法是,最好以最有效的吸引人的方式进行操作,而不仅仅是某人在此之前进行操作的方式。我认为该社区的一大优势是可以汇集众多想法并找到最佳做法的程序员。

我认为我们大多数人都对我们的代码库感到不满,并且想知道某人将什么都行之有效的动机带入了他们的代码库中。

这是做家庭作业吗?还是可能适合其他人?

回答

如果不编写所有代码,则开始看起来像这样:

/*
* 2.1 Straight flush
* 2.2 Four of a kind
* 2.3 Full house
* 2.4 Flush
* 2.5 Straight
* 2.6 Three of a kind
* 2.7 Two pair
* 2.8 One pair
* 2.9 High card
*/
// Note, the vector cards is sorted low to high. All cards have a numeric value 2-13 and a suit 0-3
int noDuces(Cards[] cards) {
    int duces = 0;
    int cursor = cards.length;
    while(cards[cursor--].value == 2) duces++;
    return duces;
}

bool isFlush(Cards [] cards) {
   int duces = noDuces(cards);
   int firstColour = cards[cards.length].colour;
   for (int i = cards.length -1; i > duces; i--) {
       if (cards[i].colour != firstColour)
           return false;
   }
   return true;
}

bool isStraight(Cards[] cards) {
    int duces = noDuces(cards);
    int usedDuces = 0;
    // TODO Handle A - 5 straight. 
   card prevCard = cards[cards.length];
    for (int i = cards.length -1; i > duces; i--) {
       if ((prevCard.value + 1) != cards[i].value) {
           if (usedDuces >= duces) {
               return false;
           }
           usedDuces++;
       }
       prevCard = cards[i];
   }
    return true;
}

回答

http://www.codingthewheel.com/archives/poker-hand-evaluator-roundup

有关扑克评估库的页面。库/算法列表

回答

可以在以下位置找到德州扑克扑克游戏评估器的完整源代码:

http://www.advancedmcode.org/poker-predictor.html

它是为Matlab构建的,GUI ID是m编码的,但是计算引擎是c ++。

它允许赔率和概率计算。在我的2.4Ghz笔记本电脑上,它可以在0.3秒内完成100000个10玩家游戏的计算。

准确的实时计算机:-)