From 9fdd7805da8889bf55324eefcc42abe42f4538f0 Mon Sep 17 00:00:00 2001 From: floty Date: Thu, 16 Oct 2008 09:21:30 +0000 Subject: [PATCH] calcCardsChance --- src/engine/local_engine/tools.cpp | 101 +++++++++++++++++++++--------- src/engine/local_engine/tools.h | 3 +- 2 files changed, 72 insertions(+), 32 deletions(-) diff --git a/src/engine/local_engine/tools.cpp b/src/engine/local_engine/tools.cpp index 9fcdb52e..68e5578b 100755 --- a/src/engine/local_engine/tools.cpp +++ b/src/engine/local_engine/tools.cpp @@ -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;icardsValue(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; } diff --git a/src/engine/local_engine/tools.h b/src/engine/local_engine/tools.h index c517ed55..29b98b80 100755 --- a/src/engine/local_engine/tools.h +++ b/src/engine/local_engine/tools.h @@ -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*); };