diff --git a/src/engine/local_engine/arraydata.cpp b/src/engine/local_engine/arraydata.cpp index aa28b707..32501652 100644 --- a/src/engine/local_engine/arraydata.cpp +++ b/src/engine/local_engine/arraydata.cpp @@ -1047,3 +1047,38 @@ void ArrayData::getHandChancePreflop(int handCode, int** values) { if (check == -1) LOG_ERROR(__FILE__ << " (" << __LINE__ << "): ERROR getHandChancePreflop - " << handCode); } + +vector< vector > ArrayData::getHandChancePreflop(int handCode) { + + int check = -1; + + int i; + + vector< vector > chance(2); + vector chance_0(10); + vector chance_1(10); + + chance[0] = chance_0; + chance[1] = chance_1; + + for(i=0;i<10;i++) { + chance[0][i] = 0; + chance[1][i] = 0; + } + + for (unsigned val = 0; val < NUM_HAND_CHANCE_PREFLOP; val++) { + if(handCode == handChancePreflop[val].hand) { + check = 1; + for(int i=0;i<10;i++) { + for(int j=0;j<2;j++) { + chance[j][i] = handChancePreflop[val].data[i][j]; + } + } + break; + } + } + if (check == -1) LOG_ERROR(__FILE__ << " (" << __LINE__ << "): ERROR getHandChancePreflop - " << handCode); + + return chance; + +} diff --git a/src/engine/local_engine/arraydata.h b/src/engine/local_engine/arraydata.h index 169b8d80..843d5623 100644 --- a/src/engine/local_engine/arraydata.h +++ b/src/engine/local_engine/arraydata.h @@ -22,6 +22,11 @@ #include +#include +#include + +using namespace std; + class ArrayData{ public: ArrayData(); @@ -29,6 +34,7 @@ public: ~ArrayData(); void getHandChancePreflop(int, int**); + vector< vector > getHandChancePreflop(int); }; #endif diff --git a/src/engine/local_engine/cardsvalue.cpp b/src/engine/local_engine/cardsvalue.cpp index ff517973..b77b74d6 100755 --- a/src/engine/local_engine/cardsvalue.cpp +++ b/src/engine/local_engine/cardsvalue.cpp @@ -563,21 +563,25 @@ int array[7][3]; } -int** CardsValue::calcCardsChance(GameState beRoID, int* playerCards, int* boardCards) +vector< vector > CardsValue::calcCardsChance(GameState beRoID, int* playerCards, int* boardCards) { int i,j; - int** hand = new int*[10]; - int cards[7]; - int sum = 0; + vector< vector > chance(2); + vector chance_0(10); + vector chance_1(10); + + chance[0] = chance_0; + chance[1] = chance_1; for(i=0;i<10;i++) { - hand[i] = new int[2]; - for(j=0;j<2;j++) { - hand[i][j] = 0; - } + chance[0][i] = 0; + chance[1][i] = 0; } + int cards[7]; + int sum = 0; + cards[0] = playerCards[0]; cards[1] = playerCards[1]; for(i=0;i<5;i++) cards[i+2] = boardCards[i]; @@ -586,7 +590,7 @@ int** CardsValue::calcCardsChance(GameState beRoID, int* playerCards, int* board case GAME_STATE_PREFLOP: { ArrayData* myArrayData = new ArrayData; - myArrayData->getHandChancePreflop(holeCardsToIntCode(playerCards),hand); + chance = myArrayData->getHandChancePreflop(holeCardsToIntCode(playerCards)); delete myArrayData; @@ -599,15 +603,15 @@ int** CardsValue::calcCardsChance(GameState beRoID, int* playerCards, int* board if(j!=cards[0] && j!=cards[1] && j!=cards[2] && j!=cards[3] && j!=cards[4]) { cards[5] = i; cards[6] = j; - (hand[cardsValue(cards,0)/100000000][0])++; + (chance[0][cardsValue(cards,0)/100000000])++; sum++; } } } } for(i=0;i<10;i++) { - if(hand[i][0] > 0) hand[i][1] = 1; - hand[i][0] = (int)(((double)hand[i][0]/(double)sum)*100.0+0.5); + if(chance[0][i] > 0) chance[1][i] = 1; + chance[0][i] = (int)(((double)chance[0][i]/(double)sum)*100.0+0.5); } } break; @@ -616,42 +620,42 @@ int** CardsValue::calcCardsChance(GameState beRoID, int* playerCards, int* board 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]) { cards[6] = i; - (hand[cardsValue(cards,0)/100000000][0])++; + (chance[0][cardsValue(cards,0)/100000000])++; sum++; } } for(i=0;i<10;i++) { - if(hand[i][0] > 0) hand[i][1] = 1; - hand[i][0] = (int)(((double)hand[i][0]/(double)sum)*100.0+0.5); + if(chance[0][i] > 0) chance[1][i] = 1; + chance[0][i] = (int)(((double)chance[0][i]/(double)sum)*100.0+0.5); } } break; case GAME_STATE_RIVER: { - hand[cardsValue(cards,0)/100000000][0] = 100; - hand[cardsValue(cards,0)/100000000][1] = 1; + chance[0][cardsValue(cards,0)/100000000] = 100; + chance[1][cardsValue(cards,0)/100000000] = 1; } break; default: { } } - return hand; + return chance; } int** CardsValue::showdown(GameState beRoID, int** playerCards, int playerCount) { - int i,j; - - int** chance = new int*[2]; - - for(i=0;i<10;i++) { - chance[i] = new int[2]; - for(j=0;j<2;j++) { - chance[i][j] = 0; - } - } - - int rand[5]; - - return chance; +// int i,j; +// +// int** chance = new int*[2]; +// +// for(i=0;i<10;i++) { +// chance[i] = new int[2]; +// for(j=0;j<2;j++) { +// chance[i][j] = 0; +// } +// } +// +// int rand[5]; +// +// return chance; } diff --git a/src/engine/local_engine/cardsvalue.h b/src/engine/local_engine/cardsvalue.h index 3ac14ab7..be9b559d 100755 --- a/src/engine/local_engine/cardsvalue.h +++ b/src/engine/local_engine/cardsvalue.h @@ -24,6 +24,11 @@ #include "arraydata.h" #include "tools.h" +#include +#include + +using namespace std; + class CardsValue{ public: CardsValue(); @@ -36,7 +41,7 @@ public: int holeCardsToIntCode(int*); int* intCodeToHoleCards(int); - int** calcCardsChance(GameState, int*, int*); + vector< vector > calcCardsChance(GameState, int*, int*); int** showdown(GameState, int**, int); }; diff --git a/src/gui/qt/gametable/mychancelabel.cpp b/src/gui/qt/gametable/mychancelabel.cpp index c06d2433..b1adb88b 100644 --- a/src/gui/qt/gametable/mychancelabel.cpp +++ b/src/gui/qt/gametable/mychancelabel.cpp @@ -23,29 +23,29 @@ MyChanceLabel::~MyChanceLabel() { } -void MyChanceLabel::refreshChance(int **chance) +void MyChanceLabel::refreshChance(vector< vector > chance) { - RFChance[0] = chance[9][0]; - SFChance[0] = chance[8][0]; - FOAKChance[0] = chance[7][0]; - FHChance[0] = chance[6][0]; - FLChance[0] = chance[5][0]; - STRChance[0] = chance[4][0]; - TOAKChance[0] = chance[3][0]; - TPChance[0] = chance[2][0]; - OPChance[0] = chance[1][0]; + RFChance[0] = chance[0][9]; + SFChance[0] = chance[0][8]; + FOAKChance[0] = chance[0][7]; + FHChance[0] = chance[0][6]; + FLChance[0] = chance[0][5]; + STRChance[0] = chance[0][4]; + TOAKChance[0] = chance[0][3]; + TPChance[0] = chance[0][2]; + OPChance[0] = chance[0][1]; HCChance[0] = chance[0][0]; - RFChance[1] = chance[9][1]; - SFChance[1] = chance[8][1]; - FOAKChance[1] = chance[7][1]; - FHChance[1] = chance[6][1]; - FLChance[1] = chance[5][1]; - STRChance[1] = chance[4][1]; - TOAKChance[1] = chance[3][1]; - TPChance[1] = chance[2][1]; + RFChance[1] = chance[1][9]; + SFChance[1] = chance[1][8]; + FOAKChance[1] = chance[1][7]; + FHChance[1] = chance[1][6]; + FLChance[1] = chance[1][5]; + STRChance[1] = chance[1][4]; + TOAKChance[1] = chance[1][3]; + TPChance[1] = chance[1][2]; OPChance[1] = chance[1][1]; - HCChance[1] = chance[0][1]; + HCChance[1] = chance[1][0]; update(); } diff --git a/src/gui/qt/gametable/mychancelabel.h b/src/gui/qt/gametable/mychancelabel.h index 9e37d0ef..e342e0a4 100644 --- a/src/gui/qt/gametable/mychancelabel.h +++ b/src/gui/qt/gametable/mychancelabel.h @@ -13,10 +13,13 @@ #define MYCHANCELABEL_H #include +#include #include #include +using namespace std; + class gameTableImpl; class MyChanceLabel : public QLabel @@ -29,7 +32,7 @@ public: void setMyW ( gameTableImpl* theValue ) { myW = theValue; } void paintEvent(QPaintEvent * event); - void refreshChance(int**); + void refreshChance(vector< vector >); void resetChance(); private: