I'm writing a poker game, but the rules are custom. I have 2 player cards and 5 community cards (arrays of structs). I need to initialize a player's possible hands (21 hands - 7 combination 5) with any combination of 5 cards (structs).
Passing in two pointers to the player and community card struct arrays, as well as a pointer to the player struct, I go through them and put all 21 in a "hands" struct array, each element containing a 5 "card" struct array in the "player" struct.
enum Value {
ONE = 1, TWO, THREE, FOUR...ACE
};
enum Suit {
CLUB = 0, DIAMOND...
};
struct card {
enum Value val;
enum Suit suit;
};
struct hand {
struct card cards[5];
}
struct player {
struct hand hands[21];
}
void makePlayer(struct player *person, struct card *personCards, struct card *commCards);
we can make this easier and just conceptualize with an array of 7 cards
void makePlayer(struct player *person, struct card *sevenCards);
My question is how to implement the combination to achieve all 21 results without hard coding them? I have a function to copy cards, just passes in two card arrays and gives them the same values. I'm just lost conceptually on the combination.
A step in the right direction would help. I'm looking more for concept proof than an actual working program. Say you have cards "p1, p2, c1, c2, c3, c4, c5". You make 21 combinations of 5 cards, order doesn't matter, you can use any cards. So: p1 p2 c1 c2 c3. Or: c1, c3, c4, p1, c5. Just no repeating combinations. So basically, given an array of 7 card structures, create 21 possible combinations of 5 of the structures without repeating any.