vector in cardsChance
This commit is contained in:
@@ -1047,3 +1047,38 @@ void ArrayData::getHandChancePreflop(int handCode, int** values) {
|
|||||||
if (check == -1) LOG_ERROR(__FILE__ << " (" << __LINE__ << "): ERROR getHandChancePreflop - " << handCode);
|
if (check == -1) LOG_ERROR(__FILE__ << " (" << __LINE__ << "): ERROR getHandChancePreflop - " << handCode);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vector< vector<int> > ArrayData::getHandChancePreflop(int handCode) {
|
||||||
|
|
||||||
|
int check = -1;
|
||||||
|
|
||||||
|
int i;
|
||||||
|
|
||||||
|
vector< vector<int> > chance(2);
|
||||||
|
vector<int> chance_0(10);
|
||||||
|
vector<int> 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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -22,6 +22,11 @@
|
|||||||
|
|
||||||
#include <core/loghelper.h>
|
#include <core/loghelper.h>
|
||||||
|
|
||||||
|
#include<iostream>
|
||||||
|
#include<vector>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
class ArrayData{
|
class ArrayData{
|
||||||
public:
|
public:
|
||||||
ArrayData();
|
ArrayData();
|
||||||
@@ -29,6 +34,7 @@ public:
|
|||||||
~ArrayData();
|
~ArrayData();
|
||||||
|
|
||||||
void getHandChancePreflop(int, int**);
|
void getHandChancePreflop(int, int**);
|
||||||
|
vector< vector<int> > getHandChancePreflop(int);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -563,21 +563,25 @@ int array[7][3];
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int** CardsValue::calcCardsChance(GameState beRoID, int* playerCards, int* boardCards)
|
vector< vector<int> > CardsValue::calcCardsChance(GameState beRoID, int* playerCards, int* boardCards)
|
||||||
{
|
{
|
||||||
int i,j;
|
int i,j;
|
||||||
|
|
||||||
int** hand = new int*[10];
|
vector< vector<int> > chance(2);
|
||||||
int cards[7];
|
vector<int> chance_0(10);
|
||||||
int sum = 0;
|
vector<int> chance_1(10);
|
||||||
|
|
||||||
|
chance[0] = chance_0;
|
||||||
|
chance[1] = chance_1;
|
||||||
|
|
||||||
for(i=0;i<10;i++) {
|
for(i=0;i<10;i++) {
|
||||||
hand[i] = new int[2];
|
chance[0][i] = 0;
|
||||||
for(j=0;j<2;j++) {
|
chance[1][i] = 0;
|
||||||
hand[i][j] = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int cards[7];
|
||||||
|
int sum = 0;
|
||||||
|
|
||||||
cards[0] = playerCards[0];
|
cards[0] = playerCards[0];
|
||||||
cards[1] = playerCards[1];
|
cards[1] = playerCards[1];
|
||||||
for(i=0;i<5;i++) cards[i+2] = boardCards[i];
|
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: {
|
case GAME_STATE_PREFLOP: {
|
||||||
ArrayData* myArrayData = new ArrayData;
|
ArrayData* myArrayData = new ArrayData;
|
||||||
|
|
||||||
myArrayData->getHandChancePreflop(holeCardsToIntCode(playerCards),hand);
|
chance = myArrayData->getHandChancePreflop(holeCardsToIntCode(playerCards));
|
||||||
|
|
||||||
delete myArrayData;
|
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]) {
|
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][0])++;
|
(chance[0][cardsValue(cards,0)/100000000])++;
|
||||||
sum++;
|
sum++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(i=0;i<10;i++) {
|
for(i=0;i<10;i++) {
|
||||||
if(hand[i][0] > 0) hand[i][1] = 1;
|
if(chance[0][i] > 0) chance[1][i] = 1;
|
||||||
hand[i][0] = (int)(((double)hand[i][0]/(double)sum)*100.0+0.5);
|
chance[0][i] = (int)(((double)chance[0][i]/(double)sum)*100.0+0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
@@ -616,42 +620,42 @@ int** CardsValue::calcCardsChance(GameState beRoID, int* playerCards, int* board
|
|||||||
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][0])++;
|
(chance[0][cardsValue(cards,0)/100000000])++;
|
||||||
sum++;
|
sum++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(i=0;i<10;i++) {
|
for(i=0;i<10;i++) {
|
||||||
if(hand[i][0] > 0) hand[i][1] = 1;
|
if(chance[0][i] > 0) chance[1][i] = 1;
|
||||||
hand[i][0] = (int)(((double)hand[i][0]/(double)sum)*100.0+0.5);
|
chance[0][i] = (int)(((double)chance[0][i]/(double)sum)*100.0+0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case GAME_STATE_RIVER: {
|
case GAME_STATE_RIVER: {
|
||||||
hand[cardsValue(cards,0)/100000000][0] = 100;
|
chance[0][cardsValue(cards,0)/100000000] = 100;
|
||||||
hand[cardsValue(cards,0)/100000000][1] = 1;
|
chance[1][cardsValue(cards,0)/100000000] = 1;
|
||||||
} break;
|
} break;
|
||||||
default: {
|
default: {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return hand;
|
return chance;
|
||||||
}
|
}
|
||||||
|
|
||||||
int** CardsValue::showdown(GameState beRoID, int** playerCards, int playerCount) {
|
int** CardsValue::showdown(GameState beRoID, int** playerCards, int playerCount) {
|
||||||
|
|
||||||
int i,j;
|
// int i,j;
|
||||||
|
//
|
||||||
int** chance = new int*[2];
|
// int** chance = new int*[2];
|
||||||
|
//
|
||||||
for(i=0;i<10;i++) {
|
// for(i=0;i<10;i++) {
|
||||||
chance[i] = new int[2];
|
// chance[i] = new int[2];
|
||||||
for(j=0;j<2;j++) {
|
// for(j=0;j<2;j++) {
|
||||||
chance[i][j] = 0;
|
// chance[i][j] = 0;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
int rand[5];
|
// int rand[5];
|
||||||
|
//
|
||||||
return chance;
|
// return chance;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,11 @@
|
|||||||
#include "arraydata.h"
|
#include "arraydata.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
|
||||||
|
#include<iostream>
|
||||||
|
#include<vector>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
class CardsValue{
|
class CardsValue{
|
||||||
public:
|
public:
|
||||||
CardsValue();
|
CardsValue();
|
||||||
@@ -36,7 +41,7 @@ public:
|
|||||||
int holeCardsToIntCode(int*);
|
int holeCardsToIntCode(int*);
|
||||||
int* intCodeToHoleCards(int);
|
int* intCodeToHoleCards(int);
|
||||||
|
|
||||||
int** calcCardsChance(GameState, int*, int*);
|
vector< vector<int> > calcCardsChance(GameState, int*, int*);
|
||||||
int** showdown(GameState, int**, int);
|
int** showdown(GameState, int**, int);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -23,29 +23,29 @@ MyChanceLabel::~MyChanceLabel()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyChanceLabel::refreshChance(int **chance)
|
void MyChanceLabel::refreshChance(vector< vector<int> > chance)
|
||||||
{
|
{
|
||||||
RFChance[0] = chance[9][0];
|
RFChance[0] = chance[0][9];
|
||||||
SFChance[0] = chance[8][0];
|
SFChance[0] = chance[0][8];
|
||||||
FOAKChance[0] = chance[7][0];
|
FOAKChance[0] = chance[0][7];
|
||||||
FHChance[0] = chance[6][0];
|
FHChance[0] = chance[0][6];
|
||||||
FLChance[0] = chance[5][0];
|
FLChance[0] = chance[0][5];
|
||||||
STRChance[0] = chance[4][0];
|
STRChance[0] = chance[0][4];
|
||||||
TOAKChance[0] = chance[3][0];
|
TOAKChance[0] = chance[0][3];
|
||||||
TPChance[0] = chance[2][0];
|
TPChance[0] = chance[0][2];
|
||||||
OPChance[0] = chance[1][0];
|
OPChance[0] = chance[0][1];
|
||||||
HCChance[0] = chance[0][0];
|
HCChance[0] = chance[0][0];
|
||||||
|
|
||||||
RFChance[1] = chance[9][1];
|
RFChance[1] = chance[1][9];
|
||||||
SFChance[1] = chance[8][1];
|
SFChance[1] = chance[1][8];
|
||||||
FOAKChance[1] = chance[7][1];
|
FOAKChance[1] = chance[1][7];
|
||||||
FHChance[1] = chance[6][1];
|
FHChance[1] = chance[1][6];
|
||||||
FLChance[1] = chance[5][1];
|
FLChance[1] = chance[1][5];
|
||||||
STRChance[1] = chance[4][1];
|
STRChance[1] = chance[1][4];
|
||||||
TOAKChance[1] = chance[3][1];
|
TOAKChance[1] = chance[1][3];
|
||||||
TPChance[1] = chance[2][1];
|
TPChance[1] = chance[1][2];
|
||||||
OPChance[1] = chance[1][1];
|
OPChance[1] = chance[1][1];
|
||||||
HCChance[1] = chance[0][1];
|
HCChance[1] = chance[1][0];
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,10 +13,13 @@
|
|||||||
#define MYCHANCELABEL_H
|
#define MYCHANCELABEL_H
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
class gameTableImpl;
|
class gameTableImpl;
|
||||||
|
|
||||||
class MyChanceLabel : public QLabel
|
class MyChanceLabel : public QLabel
|
||||||
@@ -29,7 +32,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(vector< vector<int> >);
|
||||||
void resetChance();
|
void resetChance();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user