when using the pokerstove library (https://github.com/andrewprock/pokerstove) I ran into the following problem regarding the canonization of card suits.
Here is a short code snippet that demonstrates my situation:
#include <iostream>
#include <pokerstove/peval/CardSet.h>
using namespace std;
using namespace pokerstove;
int main() {
CardSet hand1("2c3c"), hand2("2d4c"), hand3("2h4c");
cout << hand1.str() << endl;
hand2 = hand2.canonize(hand1);
hand3 = hand3.canonize(hand1);
cout << hand2.str() << endl;
cout << hand3.str() << endl;
return 0;
}
From the perspective of hand1 the other two hands are identical (they both contain the 4c and an off-suit 2). Still, after canonizing them with respect to hand1 they both remain unchanged. This is not what I would have expected.
Actually, I would have thought (and intended) that hand2 stays as it is - since 'clubs' cannot be permutated as they appear in hand1 and 'diamonds' is the next available suit for the off-suit 2. But I expected that hand3 would become identical to hand2 (by switching 'hearts' with 'diamonds').
Does anyone of you guys know why this is not working as intended?
Is there another way of capturing the fact that hands 2 and 3 are identical (from hand1's point of view)?
Any help would be appreciated!
for those who might be interested - I just found the solution to my problem myself. The following does the trick:
hand1.canonize();
if (!hand2.suitMask(Suit::Hearts())) {
hand2 = hand2.rotateSuits(0, 1, 3, 2);
}
if (!hand2.suitMask(Suit::Diamonds()) && !hand1.suitMask(Suit::Diamonds())) {
hand2 = hand2.rotateSuits(0, 3, 1, 2);
}