Bug testing AI respones
This commit is contained in:
		@@ -35,7 +35,7 @@ inline uint8_t cardContainsNumber(uint8_t *hand,uint8_t length,uint8_t number) {
 | 
			
		||||
  return 0xFF;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint8_t cardCountPairs(
 | 
			
		||||
inline uint8_t cardCountPairs(
 | 
			
		||||
  uint8_t *in, uint8_t inCount, uint8_t number, uint8_t out[CARD_SUIT_COUNT]
 | 
			
		||||
) {
 | 
			
		||||
  uint8_t i, count;
 | 
			
		||||
 
 | 
			
		||||
@@ -112,6 +112,6 @@ inline uint8_t cardGetSuit(uint8_t card);
 | 
			
		||||
inline uint8_t cardGet(uint8_t card, uint8_t suit);
 | 
			
		||||
inline uint8_t cardContains(uint8_t *hand, uint8_t length, uint8_t card);
 | 
			
		||||
inline uint8_t cardContainsNumber(uint8_t *hand,uint8_t length,uint8_t number);
 | 
			
		||||
uint8_t cardCountPairs(
 | 
			
		||||
inline uint8_t cardCountPairs(
 | 
			
		||||
  uint8_t *in, uint8_t inCount, uint8_t number, uint8_t out[CARD_SUIT_COUNT]
 | 
			
		||||
);
 | 
			
		||||
@@ -212,11 +212,14 @@ void pokerAi(uint8_t player, pokerturn_t *turn) {
 | 
			
		||||
    pokerWinnerGetForPlayer(player, &winning);
 | 
			
		||||
    BGB_printf("Winning type %u", winning.type);
 | 
			
		||||
    confidence = pokerWinnerGetTypeConfidence(winning.type);
 | 
			
		||||
    BGB_printf("Confidence %u", confidence);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // 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);
 | 
			
		||||
  BGB_printf("Callbet %u", callBet);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  // Do they need chips to call, or is it possible to check?
 | 
			
		||||
  if(callBet > 0) {
 | 
			
		||||
@@ -228,24 +231,30 @@ void pokerAi(uint8_t player, pokerturn_t *turn) {
 | 
			
		||||
      if(POKER_POTS[i].players[player] == 0) break;
 | 
			
		||||
      expectedGain += POKER_POTS[i].chips;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    // Now work out the pot odds, this is basically "how many times the callbet
 | 
			
		||||
    // could I win if I win this hand". e.g. Desirable hands will have an 
 | 
			
		||||
    // expected gain much higher than the callbet.
 | 
			
		||||
    potOdds = plyr->chips / 1000;
 | 
			
		||||
    potOdds = MATH_MAX((callBet + expectedGain), 1) / MATH_MAX(potOdds, 1);
 | 
			
		||||
 | 
			
		||||
    BGB_printf("Expected Gain and Pot Odds %u, %u", expectedGain, potOdds);
 | 
			
		||||
  } else {
 | 
			
		||||
    // If the call bet is zero then there's fairly equal odds, so let's just
 | 
			
		||||
    // take the chances out of the remainig player count.
 | 
			
		||||
    potOdds = 1000 / pokerGetRemainingBetterCount() * 2;// 0 - 1000
 | 
			
		||||
    BGB_printf("Pot Odds %u", potOdds);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Now determine the expected ROI
 | 
			
		||||
  //TODO: I think these values are a bit odd.
 | 
			
		||||
  expectedGain = (confidence*100) / (potOdds / 10);
 | 
			
		||||
  BGB_printf("Expected Gains (2) %u", expectedGain);
 | 
			
		||||
 | 
			
		||||
  // Now get a random number 0-100.
 | 
			
		||||
  random = rand() % 100;
 | 
			
		||||
  random = rand();
 | 
			
		||||
  random = random % 100;
 | 
			
		||||
 | 
			
		||||
  // Determine the max bet that the AI is willing to make. The max bet is
 | 
			
		||||
  // basically how high the AI is willing to bet.
 | 
			
		||||
@@ -264,6 +273,9 @@ void pokerAi(uint8_t player, pokerturn_t *turn) {
 | 
			
		||||
  turn->bluff = false;
 | 
			
		||||
  amount = 0;
 | 
			
		||||
 | 
			
		||||
  BGB_printf("Random Dice %u", random);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  // Now the actual AI can happen. This is basically a weight to confidence
 | 
			
		||||
  // ratio. The higher the gains and the confidence then the more likely the AI
 | 
			
		||||
  // is to betting. There are also bluff chances within here.
 | 
			
		||||
@@ -316,8 +328,6 @@ void pokerAi(uint8_t player, pokerturn_t *turn) {
 | 
			
		||||
    turn->chips = amount;
 | 
			
		||||
    turn->confidence = confidence;
 | 
			
		||||
 | 
			
		||||
    BGB_printf("Player chips %u is %u", plyr->chips, amount);
 | 
			
		||||
 | 
			
		||||
    if(plyr->chips == amount) {
 | 
			
		||||
      turn->type = POKER_TURN_TYPE_ALL_IN;
 | 
			
		||||
    } else if(amount == callBet) {
 | 
			
		||||
@@ -420,8 +430,8 @@ void pokerWinnerFillRemaining(pokerplayerwinning_t *winning) {
 | 
			
		||||
 | 
			
		||||
void pokerWinnerGetForPlayer(uint8_t playerIndex,pokerplayerwinning_t *winning){
 | 
			
		||||
  uint8_t i, j, l, card, number, suit, pairCount;
 | 
			
		||||
  int16_t index;
 | 
			
		||||
  int16_t pairs[CARD_SUIT_COUNT];
 | 
			
		||||
  uint8_t index;
 | 
			
		||||
  uint8_t pairs[CARD_SUIT_COUNT];
 | 
			
		||||
  pokerplayer_t *player;
 | 
			
		||||
 | 
			
		||||
  player = POKER_PLAYERS + playerIndex;
 | 
			
		||||
@@ -585,9 +595,8 @@ void pokerWinnerGetForPlayer(uint8_t playerIndex,pokerplayerwinning_t *winning){
 | 
			
		||||
    if(pairCount != 2) continue;
 | 
			
		||||
    
 | 
			
		||||
    for(j = 0; j < pairCount; j++) {
 | 
			
		||||
      winning->set[winning->setSize+j] = winning->full[pairs[j]];
 | 
			
		||||
      winning->set[winning->setSize++] = winning->full[pairs[j]];
 | 
			
		||||
    }
 | 
			
		||||
    winning->setSize += pairCount;
 | 
			
		||||
    if(winning->setSize != 4) continue;
 | 
			
		||||
 | 
			
		||||
    winning->type = POKER_WINNING_TYPE_TWO_PAIR;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user