Ваш Flush
алгоритм сравнивает 4
с самим собой:
//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;
^^^---------------------------^^^
Ваш алгоритм «три в своем роде» предполагает, что все три значения находятся в первых трех позициях:
//THREE OF A KIND
if( currentHand[ 0 ].GetValue() == currentHand[ 2 ].GetValue() && currentHand[ 0 ].GetValue() == currentHand[ 3 ].GetValue()
//return 3;
Возможно, три одинаковых значения хранятся в первой, средней и последней карточках в руке.
Я не знаю, как пишутся традиционные оценщики покерных рук, но у меня есть ощущение, что они выполняют некоторые дополнительные вычисления: создают массив, индексированный по значению карты, в котором хранится count числа карточек такого значения:
int reverse_hand[13] = {0};
for (int i=0; i<HAND_SIZE; i++) {
reverse_hand[currentHand[i].getValue()] += 1;
}
int pairs[2] = {-1, -1};
int pairs_count = 0;
int triple = -1;
int quad = -1;
int straight_pos = -1;
for (int i=0; i<13; i++) {
count = reverse_hand[i];
if (count == 2) {
pairs[pairs_count++] = i;
} else if (count == 3) {
triple = i;
} else if (count == 4) {
quad = i;
} else if (count == 1) {
if ((i < (13-5)) && (reverse_hand[i] == 1) &&
(reverse_hand[i+1] == 1) &&
(reverse_hand[i+2] == 1) &&
(reverse_hand[i+3] == 1) &&
(reverse_hand[i+4] == 1)) {
straight_pos = i;
}
}
if (pairs_count == 2) {
printf("You had two pairs, %d low and %d high\n", pairs[0], pairs[1]);
} else if (pairs_count == 1) {
printf("YOu had one pair of %d\n", pairs[0]);
}
if (triple >= 0) {
printf("You had a three of a kind: %d\n", triple);
}
if (quad >= 0) {
printf("You had a four of a kind: %d\n", quad);
}
if (pairs_count == 1 && triple >=0) {
printf("Full house, three %d and two %d\n", triple, pairs[0]);
}
/* code here for flush detection */
if (straight_pos >= 0) {
int p = straight_pos;
/* if straight flush print a different message */
printf("Straight, %d %d %d %d %d\n", p, p+1, p+2, p+3, p+4);
}