Removing several unnecessary allocations.
This commit is contained in:
@@ -1017,13 +1017,6 @@ static const calcHandsData handChancePreflop[] = {
|
||||
#define NUM_FLOP_VALUES (sizeof(FlopValues)/sizeof(RoundData))
|
||||
#define NUM_HAND_CHANCE_PREFLOP (sizeof(handChancePreflop)/sizeof(calcHandsData))
|
||||
|
||||
ArrayData::ArrayData()
|
||||
{
|
||||
}
|
||||
|
||||
ArrayData::~ArrayData()
|
||||
{
|
||||
}
|
||||
|
||||
void ArrayData::getHandChancePreflop(int handCode, int** values)
|
||||
{
|
||||
|
||||
@@ -27,12 +27,8 @@
|
||||
class ArrayData
|
||||
{
|
||||
public:
|
||||
ArrayData();
|
||||
|
||||
~ArrayData();
|
||||
|
||||
void getHandChancePreflop(int, int**);
|
||||
std::vector< std::vector<int> > getHandChancePreflop(int);
|
||||
static void getHandChancePreflop(int, int**);
|
||||
static std::vector< std::vector<int> > getHandChancePreflop(int);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -21,16 +21,7 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
CardsValue::CardsValue()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CardsValue::~CardsValue()
|
||||
{
|
||||
}
|
||||
|
||||
int CardsValue::holeCardsClass(int one, int two) const
|
||||
int CardsValue::holeCardsClass(int one, int two)
|
||||
{
|
||||
|
||||
if((one-1)%13<(two-1)%13) {
|
||||
@@ -214,7 +205,7 @@ int CardsValue::holeCardsClass(int one, int two) const
|
||||
|
||||
}
|
||||
|
||||
int CardsValue::holeCardsToIntCode(int* cards) const
|
||||
int CardsValue::holeCardsToIntCode(int* cards)
|
||||
{
|
||||
|
||||
// Code der HoleCards ermitteln
|
||||
@@ -238,7 +229,8 @@ int CardsValue::holeCardsToIntCode(int* cards) const
|
||||
|
||||
}
|
||||
|
||||
int* CardsValue::intCodeToHoleCards(int code) const
|
||||
/* DO NOT USE, THIS MAY LEAK MEMORY
|
||||
int* CardsValue::intCodeToHoleCards(int code)
|
||||
{
|
||||
|
||||
// one possibility !!!
|
||||
@@ -256,9 +248,9 @@ int* CardsValue::intCodeToHoleCards(int code) const
|
||||
|
||||
return cards;
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
int CardsValue::cardsValue(int* cards, int* position) const
|
||||
int CardsValue::cardsValue(int* cards, int* position)
|
||||
{
|
||||
|
||||
int array[7][3];
|
||||
@@ -637,7 +629,7 @@ int CardsValue::cardsValue(int* cards, int* position) const
|
||||
}
|
||||
|
||||
|
||||
vector< vector<int> > CardsValue::calcCardsChance(GameState beRoID, int* playerCards, int* boardCards) const
|
||||
vector< vector<int> > CardsValue::calcCardsChance(GameState beRoID, int* playerCards, int* boardCards)
|
||||
{
|
||||
int i,j;
|
||||
|
||||
@@ -660,11 +652,8 @@ vector< vector<int> > CardsValue::calcCardsChance(GameState beRoID, int* playerC
|
||||
|
||||
switch(beRoID) {
|
||||
case GAME_STATE_PREFLOP: {
|
||||
ArrayData* myArrayData = new ArrayData;
|
||||
|
||||
chance = myArrayData->getHandChancePreflop(holeCardsToIntCode(playerCards));
|
||||
|
||||
delete myArrayData;
|
||||
chance = ArrayData::getHandChancePreflop(holeCardsToIntCode(playerCards));
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -31,18 +31,14 @@
|
||||
class CardsValue
|
||||
{
|
||||
public:
|
||||
CardsValue();
|
||||
static int holeCardsClass(int, int);
|
||||
static int cardsValue(int*, int*);
|
||||
|
||||
~CardsValue();
|
||||
static int holeCardsToIntCode(int*);
|
||||
static int* intCodeToHoleCards(int);
|
||||
|
||||
int holeCardsClass(int, int) const;
|
||||
int cardsValue(int*, int*) const;
|
||||
|
||||
int holeCardsToIntCode(int*) const;
|
||||
int* intCodeToHoleCards(int) const;
|
||||
|
||||
std::vector< std::vector<int> > calcCardsChance(GameState, int*, int*) const;
|
||||
//int** showdown(GameState, int**, int);
|
||||
static std::vector< std::vector<int> > calcCardsChance(GameState, int*, int*);
|
||||
//static int** showdown(GameState, int**, int);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -847,7 +847,7 @@ static const RoundData FlopValues[] = {
|
||||
#define NUM_FLOP_VALUES (sizeof(FlopValues)/sizeof(RoundData))
|
||||
|
||||
LocalPlayer::LocalPlayer(ConfigFile *c, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB)
|
||||
: PlayerInterface(), myConfig(c), currentHand(0), myCardsValue(0), myID(id), myUniqueID(uniqueId), myType(type), myName(name), myAvatar(avatar), myDude(0), myDude4(0), myCardsValueInt(0), myOdds(-1.0), myCash(sC), mySet(0), myLastRelativeSet(0), myAction(0), myButton(mB), myActiveStatus(aS), myStayOnTableStatus(1), myTurn(0), myCardsFlip(0), myRoundStartCash(0), lastMoneyWon(0), sBluff(0), sBluffStatus(0), myWinnerState(false), m_actionTimeoutCounter(0)
|
||||
: PlayerInterface(), myConfig(c), currentHand(0), myID(id), myUniqueID(uniqueId), myType(type), myName(name), myAvatar(avatar), myDude(0), myDude4(0), myCardsValueInt(0), myOdds(-1.0), myCash(sC), mySet(0), myLastRelativeSet(0), myAction(0), myButton(mB), myActiveStatus(aS), myStayOnTableStatus(1), myTurn(0), myCardsFlip(0), myRoundStartCash(0), lastMoneyWon(0), sBluff(0), sBluffStatus(0), myWinnerState(false), m_actionTimeoutCounter(0)
|
||||
{
|
||||
|
||||
// !!!!!!!!!!!!!!!!!!!!!!!! testing !!!!!!!!!!!!!!!!!!!!!!!!
|
||||
@@ -934,10 +934,10 @@ LocalPlayer::LocalPlayer(ConfigFile *c, int id, unsigned uniqueId, PlayerType ty
|
||||
// cout << "Spieler: " << myID << " Dude: " << myDude << " Cash: " << myCash << " ActiveStatus: " << myActiveStatus << " Button: " << myButton << endl;
|
||||
|
||||
// Dude4 zuweisen
|
||||
int interval = 7;
|
||||
int count = 4;
|
||||
const int interval = 7;
|
||||
const int count = 4;
|
||||
|
||||
int *tempArray = new int[count];
|
||||
int tempArray[count];
|
||||
Tools::getRandNumber(0, 2*interval, count, tempArray, 0);
|
||||
for(i=0; i<count; i++) {
|
||||
myDude4 += tempArray[i];
|
||||
@@ -988,18 +988,11 @@ LocalPlayer::LocalPlayer(ConfigFile *c, int id, unsigned uniqueId, PlayerType ty
|
||||
}
|
||||
////////////////////////////
|
||||
|
||||
|
||||
delete[] tempArray;
|
||||
|
||||
myCardsValue = new CardsValue;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
LocalPlayer::~LocalPlayer()
|
||||
{
|
||||
delete myCardsValue;
|
||||
}
|
||||
|
||||
|
||||
@@ -4013,7 +4006,7 @@ void LocalPlayer::calcMyOdds()
|
||||
|
||||
case 0: {
|
||||
|
||||
handCode = myCardsValue->holeCardsToIntCode(myCards);
|
||||
handCode = CardsValue::holeCardsToIntCode(myCards);
|
||||
|
||||
// übergang solange preflopValue und flopValue noch nicht bereinigt
|
||||
int players = currentHand->getActivePlayerList()->size();
|
||||
@@ -4117,8 +4110,8 @@ void LocalPlayer::calcMyOdds()
|
||||
tempOpponentCardsArray[1] = j;
|
||||
tempOpponentCardsArray[6] = k;
|
||||
tempMyCardsArray[6] = k;
|
||||
tempMyCardsValue = myCardsValue->cardsValue(tempMyCardsArray,0);
|
||||
tempOpponentCardsValue = myCardsValue->cardsValue(tempOpponentCardsArray,0);
|
||||
tempMyCardsValue = CardsValue::cardsValue(tempMyCardsArray,0);
|
||||
tempOpponentCardsValue = CardsValue::cardsValue(tempOpponentCardsArray,0);
|
||||
|
||||
if(tempMyCardsValue>=tempOpponentCardsValue) countMy++;
|
||||
}
|
||||
@@ -4171,8 +4164,8 @@ void LocalPlayer::calcMyOdds()
|
||||
|
||||
tempOpponentCardsArray[0] = i;
|
||||
tempOpponentCardsArray[1] = j;
|
||||
tempMyCardsValue = myCardsValue->cardsValue(tempMyCardsArray,0);
|
||||
tempOpponentCardsValue = myCardsValue->cardsValue(tempOpponentCardsArray,0);
|
||||
tempMyCardsValue = CardsValue::cardsValue(tempMyCardsArray,0);
|
||||
tempOpponentCardsValue = CardsValue::cardsValue(tempOpponentCardsArray,0);
|
||||
|
||||
if(tempMyCardsValue>=tempOpponentCardsValue) countMy++;
|
||||
}
|
||||
@@ -4467,7 +4460,7 @@ void LocalPlayer::preflopEngine3()
|
||||
// cout << "preflop-bluff " << bluff << endl;
|
||||
|
||||
// Potential
|
||||
int potential = 10*(4*(myCardsValue->holeCardsClass(myCards[0], myCards[1]))+1*tempRand)/50-myDude;
|
||||
int potential = 10*(4*(CardsValue::holeCardsClass(myCards[0], myCards[1]))+1*tempRand)/50-myDude;
|
||||
|
||||
int setToHighest = currentHand->getCurrentBeRo()->getHighestSet() - mySet;
|
||||
|
||||
@@ -4477,7 +4470,7 @@ void LocalPlayer::preflopEngine3()
|
||||
Tools::getRandNumber(2,3,1,&tempFold,0);
|
||||
|
||||
// FOLD --> wenn Potential negativ oder HighestSet zu hoch
|
||||
if( (potential*setToHighest<0 || (setToHighest > tempFold * currentHand->getSmallBlind() && potential<1) || (setToHighest > 2 * tempFold * currentHand->getSmallBlind() && potential<2) || (setToHighest > 4 * tempFold * currentHand->getSmallBlind() && potential<3) || (setToHighest > 10 * tempFold * currentHand->getSmallBlind() && potential<4)) && myCardsValue->holeCardsClass(myCards[0], myCards[1]) < 9 && bluff > 15) {
|
||||
if( (potential*setToHighest<0 || (setToHighest > tempFold * currentHand->getSmallBlind() && potential<1) || (setToHighest > 2 * tempFold * currentHand->getSmallBlind() && potential<2) || (setToHighest > 4 * tempFold * currentHand->getSmallBlind() && potential<3) || (setToHighest > 10 * tempFold * currentHand->getSmallBlind() && potential<4)) && CardsValue::holeCardsClass(myCards[0], myCards[1]) < 9 && bluff > 15) {
|
||||
myAction=1;
|
||||
} else {
|
||||
// RAISE --> wenn hohes Potential
|
||||
@@ -4666,8 +4659,8 @@ void LocalPlayer::flopEngine3()
|
||||
tempOpponentCardsArray[6] = l;
|
||||
tempMyCardsArray[5] = k;
|
||||
tempMyCardsArray[6] = l;
|
||||
tempMyCardsValue = myCardsValue->cardsValue(tempMyCardsArray,0);
|
||||
tempOpponentCardsValue = myCardsValue->cardsValue(tempOpponentCardsArray,0);
|
||||
tempMyCardsValue = CardsValue::cardsValue(tempMyCardsArray,0);
|
||||
tempOpponentCardsValue = CardsValue::cardsValue(tempOpponentCardsArray,0);
|
||||
|
||||
if(tempMyCardsValue>=tempOpponentCardsValue) countMy++;
|
||||
|
||||
@@ -4835,8 +4828,8 @@ void LocalPlayer::turnEngine3()
|
||||
tempOpponentCardsArray[1] = j;
|
||||
tempOpponentCardsArray[6] = k;
|
||||
tempMyCardsArray[6] = k;
|
||||
tempMyCardsValue = myCardsValue->cardsValue(tempMyCardsArray,0);
|
||||
tempOpponentCardsValue = myCardsValue->cardsValue(tempOpponentCardsArray,0);
|
||||
tempMyCardsValue = CardsValue::cardsValue(tempMyCardsArray,0);
|
||||
tempOpponentCardsValue = CardsValue::cardsValue(tempOpponentCardsArray,0);
|
||||
|
||||
if(tempMyCardsValue>=tempOpponentCardsValue) countMy++;
|
||||
}
|
||||
@@ -4999,8 +4992,8 @@ void LocalPlayer::riverEngine3()
|
||||
|
||||
tempOpponentCardsArray[0] = i;
|
||||
tempOpponentCardsArray[1] = j;
|
||||
tempMyCardsValue = myCardsValue->cardsValue(tempMyCardsArray,0);
|
||||
tempOpponentCardsValue = myCardsValue->cardsValue(tempOpponentCardsArray,0);
|
||||
tempMyCardsValue = CardsValue::cardsValue(tempMyCardsArray,0);
|
||||
tempOpponentCardsValue = CardsValue::cardsValue(tempOpponentCardsArray,0);
|
||||
|
||||
if(tempMyCardsValue>=tempOpponentCardsValue) countMy++;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include <string>
|
||||
|
||||
|
||||
class CardsValue;
|
||||
class ConfigFile;
|
||||
class HandInterface;
|
||||
|
||||
@@ -286,8 +285,6 @@ private:
|
||||
ConfigFile *myConfig;
|
||||
HandInterface *currentHand;
|
||||
|
||||
CardsValue *myCardsValue;
|
||||
|
||||
// Konstanten
|
||||
int myID;
|
||||
unsigned myUniqueID;
|
||||
|
||||
@@ -23,7 +23,7 @@ using namespace std;
|
||||
|
||||
|
||||
ClientPlayer::ClientPlayer(ConfigFile *c, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB)
|
||||
: PlayerInterface(), myConfig(c), currentHand(0), myCardsValue(0), myID(id), myUniqueID(uniqueId), myType(type),
|
||||
: PlayerInterface(), myConfig(c), currentHand(0), myID(id), myUniqueID(uniqueId), myType(type),
|
||||
myName(name), myAvatar(avatar), myDude(0), myDude4(0), myCardsValueInt(0), myOdds(-1.0), myCash(sC), mySet(0), myLastRelativeSet(0),
|
||||
myAction(0), myButton(mB), myActiveStatus(aS), myStayOnTableStatus(true), myTurn(false), myCardsFlip(false), myRoundStartCash(0),
|
||||
lastMoneyWon(0), sBluff(0), sBluffStatus(false), myWinnerState(false)
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include <boost/thread.hpp>
|
||||
#include <string>
|
||||
|
||||
class CardsValue;
|
||||
class ConfigFile;
|
||||
class HandInterface;
|
||||
|
||||
@@ -149,8 +148,6 @@ private:
|
||||
ConfigFile *myConfig;
|
||||
HandInterface *currentHand;
|
||||
|
||||
CardsValue *myCardsValue;
|
||||
|
||||
// Konstanten
|
||||
const int myID;
|
||||
const unsigned myUniqueID;
|
||||
|
||||
@@ -3536,8 +3536,6 @@ void gameTableImpl::refreshVotesMonitor(int currentVotes, int numVotesNeededToKi
|
||||
|
||||
void gameTableImpl::refreshCardsChance(GameState bero)
|
||||
{
|
||||
CardsValue myCardsValue;
|
||||
|
||||
if(myConfig->readConfigInt("ShowCardsChanceMonitor")) {
|
||||
|
||||
boost::shared_ptr<PlayerInterface> humanPlayer = myStartWindow->getSession()->getCurrentGame()->getSeatsList()->front();
|
||||
@@ -3548,7 +3546,7 @@ void gameTableImpl::refreshCardsChance(GameState bero)
|
||||
humanPlayer->getMyCards(holeCards);
|
||||
myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getBoard()->getMyCards(boardCards);
|
||||
|
||||
label_chance->refreshChance(myCardsValue.calcCardsChance(bero, holeCards, boardCards));
|
||||
label_chance->refreshChance(CardsValue::calcCardsChance(bero, holeCards, boardCards));
|
||||
} else {
|
||||
label_chance->resetChance();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user