Added copilot's full house detection code with @theturtlemafia's boolean simplification. Tested.
This commit is contained in:
+12
-7
@@ -45,17 +45,22 @@ bool hand_contains_two_pair(u8 *ranks) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool hand_contains_full_house(u8* ranks) {
|
bool hand_contains_full_house(u8* ranks) {
|
||||||
bool contains_pair = false;
|
int count_three = 0;
|
||||||
bool contains_three = false;
|
int count_pair = 0;
|
||||||
for (int i = 0; i < NUM_RANKS; i++) {
|
for (int i = 0; i < NUM_RANKS; i++) {
|
||||||
if (ranks[i] == 2) {
|
if (ranks[i] >= 3) {
|
||||||
contains_pair = true;
|
count_three++;
|
||||||
}
|
}
|
||||||
if (ranks[i] == 3) {
|
else if (ranks[i] >= 2) {
|
||||||
contains_three = true;
|
count_pair++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return contains_pair && contains_three;
|
// Full house if there is:
|
||||||
|
// - at least one three-of-a-kind and at least one other pair,
|
||||||
|
// - OR at least two three-of-a-kinds (second "three" acts as pair).
|
||||||
|
// This accounts for hands with 6 or more cards even though
|
||||||
|
// they are currently not possible and probably never will be.
|
||||||
|
return (count_three >= 2 || (count_three && count_pair));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hand_contains_straight(u8 *ranks) {
|
bool hand_contains_straight(u8 *ranks) {
|
||||||
|
|||||||
Reference in New Issue
Block a user