Working on poker logic.

This commit is contained in:
2021-09-25 01:36:25 -07:00
parent e1a4abaaf8
commit 1bccf9b7e2
7 changed files with 222 additions and 74 deletions

View File

@ -18,7 +18,7 @@
/** How many cards make a winning set */
#define POKER_WINNING_SET_SIZE 5
/** Winning Types */
/** Winning Types */
#define POKER_WINNING_TYPE_NULL 0x00
#define POKER_WINNING_TYPE_ROYAL_FLUSH 0x01
#define POKER_WINNING_TYPE_STRAIGHT_FLUSH 0x02
@ -31,6 +31,17 @@
#define POKER_WINNING_TYPE_PAIR 0x09
#define POKER_WINNNIG_TYPE_HIGH_CARD 0x0A
#define POKER_WINNNIG_CONFIDENCE_ROYAL_FLUSH 1.0f
#define POKER_WINNNIG_CONFIDENCE_STRAIGHT_FLUSH 0.9f
#define POKER_WINNNIG_CONFIDENCE_FOUR_OF_A_KIND 0.85f
#define POKER_WINNNIG_CONFIDENCE_FULL_HOUSE 0.83f
#define POKER_WINNNIG_CONFIDENCE_FLUSH 0.8f
#define POKER_WINNNIG_CONFIDENCE_STRAIGHT 0.75f
#define POKER_WINNNIG_CONFIDENCE_THREE_OF_A_KIND 0.75f
#define POKER_WINNNIG_CONFIDENCE_TWO_PAIR 0.7f
#define POKER_WINNNIG_CONFIDENCE_PAIR 0.6f
#define POKER_WINNNIG_CONFIDENCE_HIGH_CARD 0.5f
/** Holds information about a player's winning state */
typedef struct {
/** The full set of both the dealer and player's hand */
@ -108,4 +119,30 @@ card_t pokerWinnerCompare(
*/
void pokerWinnerCalculate(
pokerwinner_t *winner, pokerdealer_t *dealer, pokerplayer_t *players
);
);
/**
* Get the best valued card from a given hand.
*
* @param cards Array of cards.
* @param cardCount Count of cards in the array
* @return The best card within the array.
*/
card_t pokerWinnerGetBestCard(card_t *cards, uint8_t cardCount);
/**
* Get the confidence of the bet for a given winning type.
*
* @param type Winning type type.
* @return The confidence.
*/
float pokerWinnerGetTypeConfidence(uint8_t type);
/**
* Get the weight of a card.
*
* @param card Card to get the weight of.
* @return The cards' weight.
*/
float pokerWinnerGetCardWeight(card_t card);