c++ - 扑克算法手评估器

标签 c++ poker

我正在努力让我的扑克牌评估玩家的手牌。我可以使用同花顺和千斤顶或更好的一对,但在弄清楚我将如何做其余的事情时遇到了问题。关于如何将卡片评估为适当类型的任何建议?

int Game::HandCheck()
{
    //ROYAL FLUSH
    //return 9;

    //STRAIGHT FLUSH
    //return 8;

    //FOUR OF A KIND
    //return 7;

    //FULL HOUSE
    //return 6;

    //FLUSH
    if( currentHand[ 0 ].GetSuit() == currentHand[ 1 ].GetSuit() && currentHand[ 1 ].GetSuit() == currentHand[ 2 ].GetSuit() &&
        currentHand[ 2 ].GetSuit() == currentHand[ 3 ].GetSuit() && currentHand[ 4 ].GetSuit() == currentHand[ 4 ].GetSuit() ) 
        return 5;

    //STRAIGHT
    //return 4;

    //THREE OF A KIND
    if( currentHand[ 0 ].GetValue() == currentHand[ 2 ].GetValue() && currentHand[ 0 ].GetValue() == currentHand[ 3 ].GetValue()
    //return 3;

    //TWO PAIR
    //return 2;

    //JACKS OR BETTER PAIR
    for( int i = 0; i < 5; i++ )
    {
        if( currentHand[ i ].GetValue() == 11 || currentHand[ i ].GetValue() == 12 || currentHand[ i ].GetValue() == 13 || currentHand[ i ].GetValue() == 1 )
        {
            if( currentHand[ i ].GetValue() == currentHand[ i + 1 ].GetValue() || currentHand[ i ].GetValue() == currentHand[ i + 2 ].GetValue() || //pair
            currentHand[ i ].GetValue() == currentHand[ i + 3 ].GetValue() || currentHand[ i ].GetValue() == currentHand[ i + 4 ].GetValue() )
            return 1;
        }
    }

    return 0;

}

最佳答案

我会创建一个直方图数组来进行计数。

填充数组。 如果恰好有一个桶有两个或更多个,则您有一对、三条或四条。 如果两个桶的点数为 2 或更多,则您有两对或葫芦。

关于c++ - 扑克算法手评估器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8423628/

相关文章:

javascript - 嵌套的 forEach 循环意外行为

C# 扑克库

c++ - 捕获网络状态变化事件

C++ 类空类大小 1 字节

c++ - 关于C++多态性使用的问题

Javascript 数组测试在为 True 时表现为 False

c++ - 除了尾递归之外的尾调用优化?

c++ - 析构函数末尾的段错误

python - 将一个列表中的项目移动到另一个列表中的纸牌游戏 Python

java - 实现动态奖励制度