Ejemplo n.º 1
0
static inline void calc(int argc, char** argv) {   
    StdDeck_CardMask hole, board;
    StdDeck_CardMask card;
    StdDeck_CardMask_RESET(hole);
    StdDeck_CardMask_RESET(board);
    int i, cardi;
    
    for(i = 1; i < 5; ++i) {
       StdDeck_stringToCard(argv[i], &cardi); 
       card = StdDeck_MASK(cardi);
       StdDeck_CardMask_OR(hole, hole, card);
    }
    po_probs probs;
    probs = get_probs(hole, board);
    printf("%.4f", probs.win + probs.draw);
            
    if ( argc > 7) {
    for(i = 5; i < 8; ++i) {
       StdDeck_stringToCard(argv[i], &cardi); 
       card = StdDeck_MASK(cardi);
       StdDeck_CardMask_OR(board, board, card);
    }
    probs = get_probs(hole, board);
    printf(" %.4f", probs.win + probs.draw);
    }
    
    if ( argc > 8) {
        i = 8;
       StdDeck_stringToCard(argv[i], &cardi); 
       card = StdDeck_MASK(cardi);
       StdDeck_CardMask_OR(board, board, card);
    
    probs = get_probs(hole, board);
    printf(" %.4f", probs.win + probs.draw);
    }
    
    if ( argc > 9) {
        i = 9;
       StdDeck_stringToCard(argv[i], &cardi); 
       card = StdDeck_MASK(cardi);
       StdDeck_CardMask_OR(board, board, card);
    
    probs = get_probs(hole, board);
    printf(" %.4f", probs.win + probs.draw);
    }
    
    
    
    
    printf("\n");
}
	// Helper:
	// Given a string such as "AcKcQcJcTc" representing a poker hand,
	// return an StdDeck_CardMask representing that hand.	
	extern "C" StdDeck_CardMask TextToPokerEval(const char* strHand)
	{
	   StdDeck_CardMask theHand, theCard;
	   StdDeck_CardMask_RESET(theHand);

	   if (strHand && strlen(strHand))
	   {
		  int cardIndex = -1;
		  char* curCard = const_cast<char*>(strHand);

		  while (*curCard)
		  {
			 // Take the card text and convert it to an index (0..51)
			 StdDeck_stringToCard(curCard, &cardIndex); 
			 // Convert the card index to a mask
			 theCard = StdDeck_MASK(cardIndex);
			 // Add the card (mask) to the hand
			 StdDeck_CardMask_OR(theHand, theHand, theCard);
			 // Advance to the next card (if any)
			 curCard += 2;
		  }
	   }

	   return theHand;
	}
Ejemplo n.º 3
0
int
numCardsStandard(StdDeck_CardMask mask)
{
  int r, s;
  int nbits = 0;
  for (r=StdDeck_Rank_FIRST; r<=StdDeck_Rank_LAST; r++) {
    for (s=StdDeck_Suit_FIRST; s<=StdDeck_Suit_LAST; s++) {
      StdDeck_CardMask card = StdDeck_MASK(StdDeck_MAKE_CARD(r, s));
      if (StdDeck_CardMask_ANY_SET(mask, card))
        nbits++;
    }
  }
  return nbits;
}
Ejemplo n.º 4
0
CRank169To1326Utility::CRank169To1326Utility()
{
	/*
	*  
	*/

	GeneratePreflopHandRanks1326();

	for(int hc1=0, index1326=0; hc1<51; hc1++)
	{
		for(int hc2=hc1+1; hc2<52; hc2++, index1326++)	
		{
			card_mask_for_hand1326[index1326] = StdDeck_MASK(hc1);
			StdDeck_CardMask_OR(card_mask_for_hand1326[index1326], card_mask_for_hand1326[index1326], StdDeck_MASK(hc2));

			FillRanges(hc1, hc2, index1326);
		}
	}
}
Ejemplo n.º 5
0
StdDeck_CardMask wrap_StdDeck_MASK(int index) { return StdDeck_MASK(index); }
Ejemplo n.º 6
0
void CKnnLogic::FillHandInfoStruct(int* hand)
{
	bool	new_hand, new_street, new_bet;

	hand[eDim_handId] = current_hand_id;

	/////////////////////////////
	// NEW HAND / STREET / BET //
	/////////////////////////////
	new_hand = new_street = new_bet = false;

	// New Hand
	if(gVars.get_dealerchair() != prev_dealer)	
	{
		new_hand = true;
		hand[eDim_isNew] = 1;
	}
	// New street
	else if(gVars.get_betround() != prev_br)
	{
		new_street = true;
		hand[eDim_isNew] = 2;
	}
	// New bet
	else if(prev_ntimesacted != gVars.ntimesacted)
	{
		new_bet	= true;
		hand[eDim_isNew] = 3;
	}
	// initialize hero_actions
	if(new_hand || new_street)
	{
		for(int i = 0; i < k_max_actions; i++)
			hero_actions[i] = eBet_Unknown;
	}

	hand[eDim_brNdx] = BR2NDX(gVars.get_betround());
	assert(ePreflopIndex <= hand[eDim_brNdx] && eRiverIndex >= hand[eDim_brNdx]);

	hand[eDim_timesActed] = min(gVars.ntimesacted,3);
	// save hero_actions to hand_info struct
	for(int i = 0; i < k_max_actions; i++)
		hand[eDim_Action1+i] = hero_actions[i];
	
	hand[eDim_HS] = 100 * (hand[eDim_InHand] > 0 && hand[eDim_InHand] < k_max_chairs ? hand[eDim_InHand] : 1) * gVars.get_prwin();  //0..1
	hand[eDim_Raises] = gVars.get_nopponentsraising();

	/////////////////////////////////////////////////
	//Save data normalized on the interval 0..1000://
	/////////////////////////////////////////////////
	
	// save hand169 to hand_info struct
	if(ePreflopIndex == hand[eDim_brNdx])
	{
		hand[eDim_PPot] = 0;
		hand[eDim_NPot] = 0;
	}
	else
	{
		// Calc hand potentials
		if(eRiverIndex != hand[eDim_brNdx])
		{
			// Generate card masks
			StdDeck_CardMask hero_cards = {0}, board_cards = {0};
			for(int i = 0; i < 2; i++)
			{
				int card = StdDeck_MAKE_CARD(gVars.Bot_Common_Cards[i][0]-2, ConvertSuitsForPokerEval[gVars.Bot_Common_Cards[i][1]]);
				StdDeck_CardMask_OR(hero_cards, hero_cards, StdDeck_MASK(card));
				//gLog.WriteLog(eSeverityDebug, eCatHandPotential, "Player Card: %d\n", card);
			}
			for(int i = 0; i < (1 + gVars.get_betround()); i++)
			{
				int card = StdDeck_MAKE_CARD(gVars.Bot_Common_Cards[2+i][0]-2, ConvertSuitsForPokerEval[gVars.Bot_Common_Cards[2+i][1]]);
				StdDeck_CardMask_OR(board_cards, board_cards, StdDeck_MASK(card));
				//gLog.WriteLog(eSeverityDebug, eCatHandPotential, "Board Card: %d\n", card);
			}

			// calculate potentials
			// Shouldn't this calc be moved to the server ?
			CHandPotential hp(hero_cards, board_cards);
			hp.CalcPotentials();

			// save potentials to hand_info struct
			hand[eDim_PPot]= (int)(100*hp.Ppot); //0..1
			hand[eDim_NPot] = (int)(100*hp.Npot); //0..1
		}
		else
		{
			// no such thing as ppot/npot in the river
			hand[eDim_PPot] = 0;
			hand[eDim_NPot] = 0;
		}
	}

	hand[eDim_InHand]	= gVars.nplayersplaying; //1..6 /4
	// replace me !!!
	hand[eDim_Dealt]	= gVars.get_nplayersdealt(); //1..6 /4
	// replace me !!!
	hand[eDim_ToAct]	= gVars.m_state.LeftToAct(gVars.userchair); //1..6 /4
	// replace me !!!
	hand[eDim_Balance]	= (int)(gVars.balance[gVars.userchair]); //0..+-400
	hand[eDim_InitialBalance]	= (int)(gVars.initial_balance[gVars.userchair]); //0..+-400

	hand[eDim_Call]		= (int)(gVars.call); //0..+-400
	hand[eDim_Pot]		= (int)(gVars.get_pot()); //0..+-800
}