calcCardsChance

This commit is contained in:
floty
2008-10-16 09:21:30 +00:00
parent d8e70d997d
commit 9fdd7805da
2 changed files with 72 additions and 32 deletions
+70 -31
View File
@@ -27,7 +27,7 @@
using namespace std;
void Tools::getRandNumber(int start, int end, int howMany, int* randArray, bool different) {
void Tools::getRandNumber(int start, int end, int howMany, int* randArray, bool different, int* bad) {
int r = end-start+1;
unsigned char rand_buf[4];
@@ -59,6 +59,12 @@ void Tools::getRandNumber(int start, int end, int howMany, int* randArray, bool
int *tempArray = new int[end-start+1];
for (i=0; i<(end-start+1); i++) tempArray[i]=1;
if(bad) {
for(i=0;i<(sizeof(bad)/sizeof(int));i++) {
tempArray[bad[i]]=0;
}
}
int counter(0);
while (counter < howMany) {
@@ -93,38 +99,71 @@ void Tools::getRandNumber(int start, int end, int howMany, int* randArray, bool
int* Tools::calcCardsChance(GameState beRoID, int* playerCards, int* boardCards)
{
// int playerCards[2];
CardsValue *myCardsValue = new CardsValue;
// playerCards[0] = 10;
// playerCards[1] = 20;
int preflopCalcNumber = 10000;
// int boardCards[5];
//
// boardCards[0] = 4;
// boardCards[1] = 6;
// boardCards[2] = 15;
// boardCards[3] = 30;
// boardCards[4] = 40;
//
// GameState bero = GAME_STATE_PREFLOP;
int i,j;
// switch(bero) {
// case GAME_STATE_PREFLOP: {
//
// } break;
// case GAME_STATE_FLOP: {
//
// } break;
// case GAME_STATE_TURN: {
//
// } break;
// case GAME_STATE_RIVER: {
//
// } break;
// default; {
// }
// }
int hand[10];
int cards[7];
int sum = 0;
int array[10] = { 30, 11, 100, 0, 0, 99, 78, 34, 67, 21 };
return array;
for(i=0;i<10;i++) hand[i] = 0;
cards[0] = playerCards[0];
cards[1] = playerCards[1];
for(i=0;i<5;i++) cards[i+2] = boardCards[i];
switch(beRoID) {
case GAME_STATE_PREFLOP: {
// int rand[5];
// for(i=0;i<preflopCalcNumber;i++) {
// getRandNumber(0,51,5,rand,1,playerCards);
//
// }
} break;
case GAME_STATE_FLOP: {
for(i=0;i<51;i++) {
if(i!=cards[0] && i!=cards[1] && i!=cards[2] && i!=cards[3] && i!=cards[4]) {
for(j=i+1;j<52;j++) {
if(j!=cards[0] && j!=cards[1] && j!=cards[2] && j!=cards[3] && j!=cards[4]) {
cards[5] = i;
cards[6] = j;
hand[(myCardsValue->cardsValue(cards,0))/100000000]++;
sum++;
}
}
}
}
for(i=0;i<10;i++) {
hand[i] = (int)(((double)hand[i]/(double)sum)*100.0+0.5);
}
} break;
case GAME_STATE_TURN: {
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[(myCardsValue->cardsValue(cards,0))/100000000]++;
sum++;
}
}
for(i=0;i<10;i++) {
hand[i] = (int)(((double)hand[i]/(double)sum)*100.0+0.5);
}
} break;
case GAME_STATE_RIVER: {
hand[(myCardsValue->cardsValue(cards,0))/100000000] = 100;
} break;
default: {
}
}
return hand;
}
+2 -1
View File
@@ -21,10 +21,11 @@
#define TOOLS_H
#include "game_defs.h"
#include "cardsvalue.h"
class Tools{
public:
static void getRandNumber(int, int, int, int*, bool);
static void getRandNumber(int, int, int, int*, bool, int* = 0);
static int* calcCardsChance(GameState, int*, int*);
};