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