Begin refactor.

This commit is contained in:
2021-09-18 23:13:05 -07:00
parent 98daedced9
commit 6904a46bec
143 changed files with 1706 additions and 2345 deletions

View File

@ -6,6 +6,39 @@
#pragma once
#include <dawn/dawn.h>
/** How many chips each player has by defautl */
#define POKER_BET_PLAYER_CHIPS_DEFAULT 10000
/** The default blind cost for the big blind. */
#define POKER_BET_BLIND_BIG_DEFAULT 600
/** The default blind cost for the small blind. (Defaults half big blind) */
#define POKER_BET_BLIND_SMALL_DEFAULT (POKER_BET_BLIND_BIG_DEFAULT/2)
/**
* The default betting player for the round.
*
* @param poker Pointer to the poker instance.
* @return The Poker round default betting player.
*/
#define POKER_BET_ROUND_PLAYER_DEFAULT(poker) ( \
((poker)->roundSmallBlind + 1) % POKER_PLAYER_COUNT \
)
typedef struct {
/** Blinds */
int32_t blindSmall, blindBig;
/** How big the current bet is for the round. */
int32_t currentBet;
/** For Betting round, which player is currently betting */
uint8_t better;
/** Current pot of chips */
int32_t pot;
} pokerbet_t;
/**
* Initializes/resets the poker bet context.
*

View File

@ -5,9 +5,110 @@
* https://opensource.org/licenses/MIT
*/
#pragma once
#include <dawn/dawn.h>
#include "../libs.h"
#include "../util/array.h"
////////////////////////////////////////////////////////////////////////////////
// Cards
////////////////////////////////////////////////////////////////////////////////
// Aces
#define CARD_CLUBS_TWO 0x00
#define CARD_CLUBS_THREE 0x01
#define CARD_CLUBS_FOUR 0x02
#define CARD_CLUBS_FIVE 0x03
#define CARD_CLUBS_SIX 0x04
#define CARD_CLUBS_SEVEN 0x05
#define CARD_CLUBS_EIGHT 0x06
#define CARD_CLUBS_NINE 0x07
#define CARD_CLUBS_TEN 0x08
#define CARD_CLUBS_JACK 0x09
#define CARD_CLUBS_QUEEN 0x0A
#define CARD_CLUBS_KING 0x0B
#define CARD_CLUBS_ACE 0x0C
// Diamonds
#define CARD_DIAMONDS_TWO 0x0D
#define CARD_DIAMONDS_THREE 0x0E
#define CARD_DIAMONDS_FOUR 0x0F
#define CARD_DIAMONDS_FIVE 0x10
#define CARD_DIAMONDS_SIX 0x11
#define CARD_DIAMONDS_SEVEN 0x12
#define CARD_DIAMONDS_EIGHT 0x13
#define CARD_DIAMONDS_NINE 0x14
#define CARD_DIAMONDS_TEN 0x15
#define CARD_DIAMONDS_JACK 0x16
#define CARD_DIAMONDS_QUEEN 0x17
#define CARD_DIAMONDS_KING 0x18
#define CARD_DIAMONDS_ACE 0x19
// Hearts
#define CARD_HEARTS_TWO 0x1A
#define CARD_HEARTS_THREE 0x1B
#define CARD_HEARTS_FOUR 0x1C
#define CARD_HEARTS_FIVE 0x1D
#define CARD_HEARTS_SIX 0x1E
#define CARD_HEARTS_SEVEN 0x1F
#define CARD_HEARTS_EIGHT 0x20
#define CARD_HEARTS_NINE 0x21
#define CARD_HEARTS_TEN 0x22
#define CARD_HEARTS_JACK 0x23
#define CARD_HEARTS_QUEEN 0x24
#define CARD_HEARTS_KING 0x25
#define CARD_HEARTS_ACE 0x26
// Spades
#define CARD_SPADES_TWO 0x27
#define CARD_SPADES_THREE 0x28
#define CARD_SPADES_FOUR 0x29
#define CARD_SPADES_FIVE 0x2A
#define CARD_SPADES_SIX 0x2B
#define CARD_SPADES_SEVEN 0x2C
#define CARD_SPADES_EIGHT 0x2D
#define CARD_SPADES_NINE 0x2E
#define CARD_SPADES_TEN 0x2F
#define CARD_SPADES_JACK 0x30
#define CARD_SPADES_QUEEN 0x31
#define CARD_SPADES_KING 0x32
#define CARD_SPADES_ACE 0x33
////////////////////////////////////////////////////////////////////////////////
// Suits
////////////////////////////////////////////////////////////////////////////////
#define CARD_SUIT_CLUBS 0x00
#define CARD_SUIT_DIAMONDS 0x01
#define CARD_SUIT_HEARTS 0x02
#define CARD_SUIT_SPADES 0x03
////////////////////////////////////////////////////////////////////////////////
// Card numbers
////////////////////////////////////////////////////////////////////////////////
#define CARD_TWO 0x00
#define CARD_THREE 0x01
#define CARD_FOUR 0x02
#define CARD_FIVE 0x03
#define CARD_SIX 0x04
#define CARD_SEVEN 0x05
#define CARD_EIGHT 0x06
#define CARD_NINE 0x07
#define CARD_TEN 0x08
#define CARD_JACK 0x09
#define CARD_QUEEN 0x0A
#define CARD_KING 0x0B
#define CARD_ACE 0x0C
/** Count of cards in each suit */
#define CARD_COUNT_PER_SUIT 13
/** Count of suits */
#define CARD_SUIT_COUNT 4
/** Standard Card Deck Size */
#define CARD_DECK_SIZE 52
/** Type Representing a card's id */
typedef uint8_t card_t;
/**
* Returns the suit of a given card.
* @param card to get the suit for.

View File

@ -4,10 +4,35 @@
// https://opensource.org/licenses/MIT
#pragma once
#include <dawn/dawn.h>
#include "../libs.h"
#include "poker.h"
#include "card.h"
#include "player.h"
/** How many cards the dealer can hold in their hand */
#define POKER_DEALER_HAND_SIZE 5
/** How many cards the grave can hold */
#define POKER_DEALER_GRAVE_SIZE CARD_DECK_SIZE
/** Which VN Character index is the dealer */
#define POKER_DEALER_INDEX POKER_PLAYER_HUMAN_INDEX
/** Representation of the dealer state */
typedef struct {
/** Current Card Deck */
card_t deck[CARD_DECK_SIZE];
uint8_t deckSize;
/** Dealer Hand */
card_t cards[POKER_DEALER_HAND_SIZE];
uint8_t cardsFacing;
/** Card grave (where spent cards go when burned */
card_t grave[POKER_DEALER_GRAVE_SIZE];
uint8_t graveSize;
} pokerdealer_t;
/**
* Initializes/Resets a dealer state.
*

View File

@ -5,9 +5,55 @@
* https://opensource.org/licenses/MIT
*/
#include <dawn/dawn.h>
#pragma once
#include "../libs.h"
#include "card.h"
/** How many cards a player can hold in their hand */
#define POKER_PLAYER_HAND 2
/** How many players in a poker game (excludes dealer) */
#define POKER_PLAYER_COUNT 5
////////////////////////////////////////////////////////////////////////////////
// Player States
////////////////////////////////////////////////////////////////////////////////
/** State for whether or not a player has folded */
#define POKER_PLAYER_STATE_FOLDED flagDefine(0)
/** State for whether or not a player is showing their hand */
#define POKER_PLAYER_STATE_SHOWING flagDefine(1)
/** State for whether or not the player is out */
#define POKER_PLAYER_STATE_OUT flagDefine(2)
/** Flag that is reset at the start of each round, and set when move occurs. */
#define POKER_PLAYER_STATE_ROUND_MOVE flagDefine(3)
/** The index that the player who is the human... is */
#define POKER_PLAYER_HUMAN_INDEX 0x02
////////////////////////////////////////////////////////////////////////////////
// Player Definition
////////////////////////////////////////////////////////////////////////////////
/** Poker Player State */
typedef struct {
/** Cards in the players' hand */
card_t cards[POKER_PLAYER_HAND];
uint8_t cardCount;
/** Current State of player */
uint8_t state;
/** Chips in players' posession */
int32_t chips;
/** Current bet in current round player has placed */
int32_t currentBet;
} pokerplayer_t;
/**
* Returns true if the player is still alive and in the current game/
* Defined as: Not out, not folded.

View File

@ -6,4 +6,45 @@
*/
#pragma once
#include <dawn/dawn.h>
#include "../libs.h"
/** How many cards to deal each player during the deal round */
#define POKER_DEAL_CARD_EACH 2
/** How many cards are dealt for the flop, turn and river */
#define POKER_FLOP_CARD_COUNT 3
#define POKER_TURN_CARD_COUNT 1
#define POKER_RIVER_CARD_COUNT 1
#define POKER_STATE_NULL 0x00
#define POKER_STATE_STARTING_MATCH 0x01
#define POKER_STATE_STARTING_ROUND 0x02
#define POKER_STATE_TAKING_BLINDS 0x03
#define POKER_STATE_DEALING 0x04
#define POKER_STATE_CARDS_FLOPPING 0x05
#define POKER_STATE_BETTING 0x06
#define POKER_STATE_DECIDING_WINNER 0x07
typedef struct {
/** Poker betting state */
pokerbet_t bet;
/** Player States */
pokerdealer_t dealer;
pokerplayer_t players[POKER_PLAYER_COUNT];
/** Winning player states */
pokerwinner_t winner;
/** The current player that is the dealer */
uint8_t roundDealer;
/** Which player is the small blind for this round */
uint8_t roundSmallBlind;
/** Which player is the big blind for this round */
uint8_t roundBigBlind;
uint8_t state;
} poker_t;

View File

@ -6,7 +6,24 @@
*/
#pragma once
#include <dawn/dawn.h>
#include "../libs.h"
#define POKER_TURN_TYPE_OUT 0x00
#define POKER_TURN_TYPE_FOLD 0x01
#define POKER_TURN_TYPE_BET 0x02
#define POKER_TURN_TYPE_CALL 0x03
#define POKER_TURN_TYPE_ALL_IN 0x04
#define POKER_TURN_TYPE_CHECK 0x05
/** The turn that a player/the AI decided to do for its turn */
typedef struct {
/** What type of action the turn is */
uint8_t type;
/** How many chips they did in their turn (if applicable) */
int32_t chips;
/** How confident the AI is about their turn. */
float confidence;
} pokerturn_t;
/**
* Returns the AI result for a turn done by a non human player.

View File

@ -6,9 +6,53 @@
*/
#pragma once
#include <dawn/dawn.h>
#include "../libs.h"
#include "card.h"
#include "player.h"
#include "winner.h"
/** Size of the FULL hand used to calculate a winning. */
#define POKER_WINNING_FULL_SIZE POKER_PLAYER_HAND+POKER_DEALER_HAND_SIZE
/** How many cards make a winning set */
#define POKER_WINNING_SET_SIZE 5
/** Winning Types */
#define POKER_WINNING_TYPE_NULL 0x00
#define POKER_WINNING_TYPE_ROYAL_FLUSH 0x01
#define POKER_WINNING_TYPE_STRAIGHT_FLUSH 0x02
#define POKER_WINNING_TYPE_FOUR_OF_A_KIND 0x03
#define POKER_WINNING_TYPE_FULL_HOUSE 0x04
#define POKER_WINNING_TYPE_FLUSH 0x05
#define POKER_WINNING_TYPE_STRAIGHT 0x06
#define POKER_WINNING_TYPE_THREE_OF_A_KIND 0x07
#define POKER_WINNING_TYPE_TWO_PAIR 0x08
#define POKER_WINNING_TYPE_PAIR 0x09
#define POKER_WINNNIG_TYPE_HIGH_CARD 0x0A
/** Holds information about a player's winning state */
typedef struct {
/** The full set of both the dealer and player's hand */
card_t full[POKER_WINNING_FULL_SIZE];
uint8_t fullSize;
/** Holds the winning set */
card_t set[POKER_WINNING_SET_SIZE];
uint8_t setSize;
/** Winning Type */
uint8_t type;
/** If there was a kicker card it will be here, otherwise -1 for no kicker */
card_t kicker;
} pokerplayerwinning_t;
typedef struct {
/** Winning States */
pokerplayerwinning_t winnings[POKER_PLAYER_COUNT];
uint8_t winners[POKER_PLAYER_COUNT];
uint8_t winnerCount;
} pokerwinner_t;
/**
* Returns the full hand for a given player including the best cards on the