Committing progress

This commit is contained in:
2022-01-13 08:06:53 -08:00
parent 5620d6c517
commit 0cbc9a8d52
4 changed files with 82 additions and 24 deletions

View File

@@ -116,17 +116,76 @@ void pokerNewRound() {
}
inline void pokerBet(uint8_t player, uint16_t amount) {
// TODO: This may become a function because if a player doesn't have enough
// chips to bet to the active pot, then the pot needs to autosplit, take those
// who have bet into the pot up to the amount that the player betting can bet,
// and push them into a new pot.
// There also needs to be a limit on this, for example;
// player 0 has $1200, and bets $1000, he can't bet more than that ever.
// player 1 has $1000, and bets all of it. The remanin
// player 2 has $700, and bets all o it. A new $300 sidepot auto creates
// player 3 has $500 and bets all of it, Another sidepot with $200 is auto made.
// TODO: This may become a function because if a player doesn't have enough
// chips to bet to the active pot, then the pot needs to autosplit, take those
// who have bet into the pot up to the amount that the player betting can bet,
// and push them into a new pot.
// There also needs to be a limit on this, for example;
// player 0 has $1200, and bets $1000, they can't bet more than that ever.
// player 1 has $1000, and bets all of it. The remanin
// player 2 has $700, and bets all o it. A new $300 sidepot auto creates
// player 3 has $500 and bets all of it, Another sidepot with $200 is auto made.
POKER_PLAYERS[player].state |= POKER_PLAYER_STATE_HAS_BET_THIS_ROUND;
POKER_PLAYERS[player].chips -= amount;
POKER_POTS[POKER_POT_CURRENT].chips += amount;
POKER_POTS[POKER_POT_CURRENT].players[player] += amount;
POKER_POTS[POKER_POT_CURRENT].call = MATH_MAX(
amount, POKER_POTS[POKER_POT_CURRENT].players[player]
);
}
POKER_PLAYERS[player].chips -= amount;\
POKER_POTS[POKER_POT_CURRENT].chips += amount;\
POKER_POTS[POKER_POT_CURRENT].call = amount;
inline uint8_t pokerGetCallBet(uint8_t player) {
return (
POKER_POTS[POKER_POT_CURRENT].call -
POKER_POTS[POKER_POT_CURRENT].players[POKER_PLAYER_BETTER]
);
}
void pokerAi(uint8_t player) {
uint8_t i, cardNumber0, cardNumber1, suitNumber0, suitNumber1;
uint16_t callBet;
uint8_t confidence;// TODO: Determine type.
pokerplayer_t *plyr = POKER_PLAYERS + player;
// The following logic is heavily inspired by;
// https://github.com/gorel/C-Poker-AI/blob/master/src/common/pokerai.c
// But with some changes and smarts added by me. The original source code will
// essentially just run a crap tun of simulated games and get the times that
// they are expected to win from those games, but I'm just going to use the
// odds of the hand being the winning hand.
// Is this preflop?
if(POKER_COMMUNITY_SIZE == 0) {
// Get the hand weight
cardNumber0 = cardGetNumber(plyr->hand[0]);
cardNumber1 = cardGetNumber(plyr->hand[1]);
suitNumber0 = cardGetSuit(plyr->hand[0]);
suitNumber1 = cardGetSuit(plyr->hand[1]);
// Get delta between cards
i = MATH_ABS(cardNumber0 - cardNumber1);
// Get card weight
confidence = cardNumber0 + cardNumber1;
if(cardNumber0 == cardNumber1) {// Pairs
confidence += 6;
} else if(suitNumber0 == suitNumber1) {// Same suit
confidence += 4;
}
// Get difference from cards for guessing flush
if(i > 4) {
confidence -= 4;
} else if(i > 2) {
confidence -= i;
}
} else {
// Simulate my hand being the winning hand, use that as the confidence
// TODO: Repurpose old code lmao. Just take it from Dawn-C
}
// Now we know how confident the AI is, let's put a chip value to that weight
// How many chips to call?
callBet = pokerGetCallBet(player);
}