calcHandsChance

This commit is contained in:
floty
2008-10-17 10:58:03 +00:00
parent dae1eb1605
commit 9d77cbedeb
6 changed files with 43 additions and 22 deletions
+19
View File
@@ -1017,6 +1017,9 @@ static const calcHandsData handChancePreflop[] =
{ 12120, { { 0,0}, { 36,1}, { 40,1}, { 12,1}, { 1,1}, { 2,1}, { 9,1}, { 1,1}, { 0,1}, { 0,1} } } { 12120, { { 0,0}, { 36,1}, { 40,1}, { 12,1}, { 1,1}, { 2,1}, { 9,1}, { 1,1}, { 0,1}, { 0,1} } }
}; };
#define NUM_PREFLOP_VALUES (sizeof(PreflopValues)/sizeof(RoundData))
#define NUM_FLOP_VALUES (sizeof(FlopValues)/sizeof(RoundData))
#define NUM_HAND_CHANCE_PREFLOP (sizeof(handChancePreflop)/sizeof(calcHandsData))
ArrayData::ArrayData() ArrayData::ArrayData()
{ {
@@ -1025,3 +1028,19 @@ ArrayData::ArrayData()
ArrayData::~ArrayData() ArrayData::~ArrayData()
{ {
} }
void ArrayData::getHandChancePreflop(int handCode, int** values) {
for (unsigned val = 0; val < NUM_HAND_CHANCE_PREFLOP; val++) {
if(handCode == handChancePreflop[val].hand) {
for(int i=0;i<10;i++) {
for(int j=0;j<2;j++) {
values[i][j] = handChancePreflop[val].data[i][j];
}
}
break;
}
}
// if (myOdds == -1) LOG_ERROR(__FILE__ << " (" << __LINE__ << "): ERROR myOdds - " << handCode);
}
+1 -1
View File
@@ -26,7 +26,7 @@ public:
~ArrayData(); ~ArrayData();
int* getHandChancePreflop(int); void getHandChancePreflop(int, int**);
}; };
#endif #endif
+10 -8
View File
@@ -563,15 +563,17 @@ int array[7][3];
} }
int* CardsValue::calcCardsChance(GameState beRoID, int* playerCards, int* boardCards) int** CardsValue::calcCardsChance(GameState beRoID, int* playerCards, int* boardCards)
{ {
int i,j; int i,j;
int* hand = new int[10]; int** hand = new int*[10];
int cards[7]; int cards[7];
int sum = 0; int sum = 0;
for(i=0;i<10;i++) hand[i] = 0; for(i=0;i<10;i++) {
for(j=0;j<2;j++) hand[i][j] = 0;
}
cards[0] = playerCards[0]; cards[0] = playerCards[0];
cards[1] = playerCards[1]; cards[1] = playerCards[1];
@@ -595,14 +597,14 @@ int* CardsValue::calcCardsChance(GameState beRoID, int* playerCards, int* boardC
if(j!=cards[0] && j!=cards[1] && j!=cards[2] && j!=cards[3] && j!=cards[4]) { if(j!=cards[0] && j!=cards[1] && j!=cards[2] && j!=cards[3] && j!=cards[4]) {
cards[5] = i; cards[5] = i;
cards[6] = j; cards[6] = j;
hand[cardsValue(cards,0)/100000000]++; (hand[cardsValue(cards,0)/100000000][0])++;
sum++; sum++;
} }
} }
} }
} }
for(i=0;i<10;i++) { for(i=0;i<10;i++) {
hand[i] = (int)(((double)hand[i]/(double)sum)*100.0+0.5); hand[i][0] = (int)(((double)hand[i][0]/(double)sum)*100.0+0.5);
} }
} break; } break;
@@ -611,17 +613,17 @@ int* CardsValue::calcCardsChance(GameState beRoID, int* playerCards, int* boardC
for(i=0;i<52;i++) { for(i=0;i<52;i++) {
if(i!=cards[0] && i!=cards[1] && i!=cards[2] && i!=cards[3] && i!=cards[4] && i!=cards[5]) { if(i!=cards[0] && i!=cards[1] && i!=cards[2] && i!=cards[3] && i!=cards[4] && i!=cards[5]) {
cards[6] = i; cards[6] = i;
hand[cardsValue(cards,0)/100000000]++; (hand[cardsValue(cards,0)/100000000][0])++;
sum++; sum++;
} }
} }
for(i=0;i<10;i++) { for(i=0;i<10;i++) {
hand[i] = (int)(((double)hand[i]/(double)sum)*100.0+0.5); hand[i][0] = (int)(((double)hand[i][0]/(double)sum)*100.0+0.5);
} }
} break; } break;
case GAME_STATE_RIVER: { case GAME_STATE_RIVER: {
hand[cardsValue(cards,0)/100000000] = 100; hand[cardsValue(cards,0)/100000000][0] = 100;
} break; } break;
default: { default: {
} }
+1 -1
View File
@@ -34,7 +34,7 @@ public:
int holeCardsToIntCode(int*); int holeCardsToIntCode(int*);
int* intCodeToHoleCards(int); int* intCodeToHoleCards(int);
int* calcCardsChance(GameState, int*, int*); int** calcCardsChance(GameState, int*, int*);
}; };
+11 -11
View File
@@ -23,18 +23,18 @@ MyChanceLabel::~MyChanceLabel()
{ {
} }
void MyChanceLabel::refreshChance(int *chance) void MyChanceLabel::refreshChance(int **chance)
{ {
RFChance = chance[9]; RFChance = chance[9][0];
SFChance = chance[8]; SFChance = chance[8][0];
FOAKChance = chance[7]; FOAKChance = chance[7][0];
FHChance = chance[6]; FHChance = chance[6][0];
FLChance = chance[5]; FLChance = chance[5][0];
STRChance = chance[4]; STRChance = chance[4][0];
TOAKChance = chance[3]; TOAKChance = chance[3][0];
TPChance = chance[2]; TPChance = chance[2][0];
OPChance = chance[1]; OPChance = chance[1][0];
HCChance = chance[0]; HCChance = chance[0][0];
update(); update();
} }
+1 -1
View File
@@ -29,7 +29,7 @@ public:
void setMyW ( gameTableImpl* theValue ) { myW = theValue; } void setMyW ( gameTableImpl* theValue ) { myW = theValue; }
void paintEvent(QPaintEvent * event); void paintEvent(QPaintEvent * event);
void refreshChance(int*); void refreshChance(int**);
void resetChance(); void resetChance();
private: private: