complete integration of new cards value function with an additional auxiliary function; renaming some variables; comment old code
This commit is contained in:
@@ -636,7 +636,7 @@ int CardsValue::cardsValueOld(int cards[7], int position[5])
|
||||
// Karten fr den Vierling-, Full-House-, Drilling- und Paartest umsortieren
|
||||
for(k1=0; k1<7; k1++) {
|
||||
for(k2=k1+1; k2<7; k2++) {
|
||||
if(array[k1][1]<array[k2][1]) {
|
||||
if(array[k1][1]<array[k2][1] || (array[k1][1]==array[k2][1] && array[k1][0]<array[k2][0])) { // gleiche kartenwerte nach farben abwärts
|
||||
ktemp[0] = array[k1][0];
|
||||
ktemp[1] = array[k1][1];
|
||||
ktemp[2] = array[k1][2];
|
||||
@@ -650,22 +650,22 @@ int CardsValue::cardsValueOld(int cards[7], int position[5])
|
||||
}
|
||||
}
|
||||
|
||||
// nach Position sortieren: erst board, dann hole cards
|
||||
for(k1=0; k1<7; k1++) {
|
||||
for(k2=k1+1; k2<7; k2++) {
|
||||
if(array[k1][1]==array[k2][1] && array[k1][2]<array[k2][2]) {
|
||||
ktemp[0] = array[k1][0];
|
||||
ktemp[1] = array[k1][1];
|
||||
ktemp[2] = array[k1][2];
|
||||
array[k1][0] = array[k2][0];
|
||||
array[k1][1] = array[k2][1];
|
||||
array[k1][2] = array[k2][2];
|
||||
array[k2][0] = ktemp[0];
|
||||
array[k2][1] = ktemp[1];
|
||||
array[k2][2] = ktemp[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
// // nach Position sortieren: erst board, dann hole cards
|
||||
// for(k1=0; k1<7; k1++) {
|
||||
// for(k2=k1+1; k2<7; k2++) {
|
||||
// if(array[k1][1]==array[k2][1] && array[k1][2]<array[k2][2]) {
|
||||
// ktemp[0] = array[k1][0];
|
||||
// ktemp[1] = array[k1][1];
|
||||
// ktemp[2] = array[k1][2];
|
||||
// array[k1][0] = array[k2][0];
|
||||
// array[k1][1] = array[k2][1];
|
||||
// array[k1][2] = array[k2][2];
|
||||
// array[k2][0] = ktemp[0];
|
||||
// array[k2][1] = ktemp[1];
|
||||
// array[k2][2] = ktemp[2];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// auf Vierling (Klasse 7) testen
|
||||
for(j1=0; j1<4; j1++) {
|
||||
@@ -2578,10 +2578,38 @@ int CardsValue::bitcount(int in)
|
||||
while (in) {
|
||||
count++ ;
|
||||
in &= (in - 1) ;
|
||||
|
||||
}
|
||||
return count ;
|
||||
}
|
||||
|
||||
int
|
||||
CardsValue::bestHandToPosition(int bestHand[4], int cardArray[7], int position[5])
|
||||
{
|
||||
|
||||
for(int card_idx=0; card_idx<5; card_idx++) position[card_idx] = -1;
|
||||
|
||||
int position_ctr = 0;
|
||||
for(int color_idx=0; color_idx<4; color_idx++) {
|
||||
for(int card_idx_1=0; card_idx_1<13; card_idx_1++) {
|
||||
if(bestHand[color_idx] & (1<<card_idx_1)) {
|
||||
for(int card_idx_2=0; card_idx_2<7; card_idx_2++) {
|
||||
if(cardArray[card_idx_2] == color_idx*13+card_idx_1) {
|
||||
if(position_ctr<5) {
|
||||
position[position_ctr] = card_idx_2;
|
||||
position_ctr++;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(position_ctr!=5) return 0;
|
||||
else return 1;
|
||||
}
|
||||
|
||||
|
||||
//int** CardsValue::showdown(GameState beRoID, int** playerCards, int playerCount) {
|
||||
//
|
||||
|
||||
@@ -49,7 +49,7 @@ class CardsValue
|
||||
public:
|
||||
static int holeCardsClass(int, int);
|
||||
static int cardsValueShort(int[4]);
|
||||
static int cardsValue(int[4], int[4]);
|
||||
static int cardsValue(int[4], int[4] = 0);
|
||||
static KickerValue determineKickerValue(int, int, int);
|
||||
static int cardsValueOld(int[7], int[5]);
|
||||
static std::string determineHandName(int myCardsValueInt, PlayerList activePlayerList);
|
||||
@@ -60,6 +60,7 @@ public:
|
||||
static std::vector< std::vector<int> > calcCardsChance(GameState, int[2], int[5]);
|
||||
|
||||
static int bitcount(int in);
|
||||
static int bestHandToPosition(int bestHand[4], int cardArray[7], int position[5]);
|
||||
//static int** showdown(GameState, int**, int);
|
||||
|
||||
};
|
||||
|
||||
@@ -147,26 +147,26 @@ void LocalBeRo::run()
|
||||
//log the turned cards
|
||||
if(!logBoardCardsDone) {
|
||||
|
||||
int tempBoardCardsArray[5];
|
||||
int boardCards[5];
|
||||
|
||||
myHand->getBoard()->getMyCards(tempBoardCardsArray);
|
||||
myHand->getBoard()->getMyCards(boardCards);
|
||||
|
||||
switch(myBeRoID) {
|
||||
case GAME_STATE_FLOP:
|
||||
myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2]);
|
||||
myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, boardCards[0], boardCards[1], boardCards[2]);
|
||||
break;
|
||||
case GAME_STATE_TURN:
|
||||
myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2], tempBoardCardsArray[3]);
|
||||
myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, boardCards[0], boardCards[1], boardCards[2], boardCards[3]);
|
||||
break;
|
||||
case GAME_STATE_RIVER:
|
||||
myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2], tempBoardCardsArray[3], tempBoardCardsArray[4]);
|
||||
myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, boardCards[0], boardCards[1], boardCards[2], boardCards[3], boardCards[4]);
|
||||
|
||||
break;
|
||||
default: {
|
||||
LOG_ERROR(__FILE__ << " (" << __LINE__ << "): ERROR - wrong myBeRoID");
|
||||
}
|
||||
}
|
||||
if(myHand->getLog()) myHand->getLog()->logBoardCards(tempBoardCardsArray);
|
||||
if(myHand->getLog()) myHand->getLog()->logBoardCards(boardCards);
|
||||
logBoardCardsDone = true;
|
||||
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost:
|
||||
|
||||
// generate cards and assign to board and player
|
||||
const int NumCards = 52;
|
||||
int cardsArray[NumCards] = {
|
||||
int cards[NumCards] = {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
||||
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
|
||||
20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
|
||||
@@ -66,49 +66,50 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost:
|
||||
40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
|
||||
50, 51
|
||||
};
|
||||
Tools::ShuffleArrayNonDeterministic(cardsArray, NumCards);
|
||||
int tempBoardArray[5];
|
||||
int tempPlayerArray[2];
|
||||
int tempPlayerAndBoardArray[7];
|
||||
int bestHandPos[5];
|
||||
Tools::ShuffleArrayNonDeterministic(cards, NumCards);
|
||||
int boardCards[5];
|
||||
int playerHoleCards[2];
|
||||
int playerCards[7];
|
||||
int sBluff;
|
||||
|
||||
// board cards
|
||||
for(i=0; i<5; i++) tempBoardArray[i] = cardsArray[i];
|
||||
for(i=0; i<5; i++) boardCards[i] = cards[i];
|
||||
|
||||
// debug mode
|
||||
if(myLog) myLog->debugMode_getBoardCards(tempBoardArray,myID);
|
||||
if(myLog) myLog->debugMode_getBoardCards(boardCards,myID);
|
||||
|
||||
// prepare whole player hand
|
||||
for(i=0; i<5; i++) tempPlayerAndBoardArray[i+2] = tempBoardArray[i];
|
||||
for(i=0; i<5; i++) playerCards[i+2] = boardCards[i];
|
||||
|
||||
k = 0;
|
||||
myBoard->setMyCards(tempBoardArray);
|
||||
myBoard->setMyCards(boardCards);
|
||||
for(it=activePlayerList->begin(); it!=activePlayerList->end(); ++it, k++) {
|
||||
|
||||
(*it)->getMyBestHandPosition(bestHandPos);
|
||||
|
||||
// hole cards
|
||||
for(j=0; j<2; j++) tempPlayerArray[j] = cardsArray[2*k+j+5];
|
||||
|
||||
// debug mode
|
||||
if(myLog) myLog->debugMode_getPlayerCards(tempPlayerArray,myID,k);
|
||||
for(j=0; j<2; j++) playerHoleCards[j] = cards[2*k+j+5];
|
||||
(*it)->setMyHoleCards(playerHoleCards);
|
||||
if(myLog) myLog->debugMode_getPlayerCards(playerHoleCards,myID,k); // debug mode
|
||||
|
||||
// complete whole player hand
|
||||
for(j=0; j<2; j++) tempPlayerAndBoardArray[j] = tempPlayerArray[j];
|
||||
for(j=0; j<2; j++) playerCards[j] = playerHoleCards[j];
|
||||
|
||||
(*it)->setMyHoleCards(tempPlayerArray);
|
||||
(*it)->setMyCardsValueInt(CardsValue::cardsValueOld(tempPlayerAndBoardArray, bestHandPos));
|
||||
(*it)->setMyBestHandPosition(bestHandPos);
|
||||
(*it)->setMyRoundStartCash((*it)->getMyCash());
|
||||
// determine cards value
|
||||
int bestHand[4] = { 0,0,0,0 };
|
||||
int playerCardsColor[4] = { 0,0,0,0 };
|
||||
for(j=0; j<7; j++) playerCardsColor[playerCards[j]/13] |= (1 << playerCards[j]%13);
|
||||
(*it)->setMyCardsValueInt(CardsValue::cardsValue(playerCardsColor,bestHand));
|
||||
|
||||
// error-check
|
||||
for(j=0; j<5; j++) {
|
||||
if (bestHandPos[j] == -1) {
|
||||
LOG_ERROR(__FILE__ << " (" << __LINE__ << "): ERROR getMyBestHandPosition");
|
||||
}
|
||||
// determine position of best 5 cards
|
||||
int bestHandPos[5];
|
||||
if(CardsValue::bestHandToPosition(bestHand,playerCards,bestHandPos)) {
|
||||
(*it)->setMyBestHandPosition(bestHandPos);
|
||||
} else {
|
||||
LOG_ERROR(__FILE__ << " (" << __LINE__ << "): ERROR getMyBestHandPosition");
|
||||
}
|
||||
|
||||
// set round start cash
|
||||
(*it)->setMyRoundStartCash((*it)->getMyCash());
|
||||
|
||||
// set sBluff for all players --> TODO for ai-player in internet
|
||||
if((*it)->getMyID() != 0) {
|
||||
Tools::GetRand(1, 100, 1, &sBluff);
|
||||
@@ -394,11 +395,11 @@ void LocalHand::switchRounds()
|
||||
|
||||
//log board cards for allin
|
||||
if(currentRound >= GAME_STATE_FLOP) {
|
||||
int tempBoardCardsArray[5];
|
||||
int boardCards[5];
|
||||
|
||||
myBoard->getMyCards(tempBoardCardsArray);
|
||||
myGui->logDealBoardCardsMsg(currentRound, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2], tempBoardCardsArray[3], tempBoardCardsArray[4]);
|
||||
if(myLog) myLog->logBoardCards(tempBoardCardsArray);
|
||||
myBoard->getMyCards(boardCards);
|
||||
myGui->logDealBoardCardsMsg(currentRound, boardCards[0], boardCards[1], boardCards[2], boardCards[3], boardCards[4]);
|
||||
if(myLog) myLog->logBoardCards(boardCards);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -282,10 +282,10 @@ public:
|
||||
void turnEngine();
|
||||
void riverEngine();
|
||||
|
||||
void preflopEngine3();
|
||||
void flopEngine3();
|
||||
void turnEngine3();
|
||||
void riverEngine3();
|
||||
// void preflopEngine3();
|
||||
// void flopEngine3();
|
||||
// void turnEngine3();
|
||||
// void riverEngine3();
|
||||
|
||||
int flopCardsValue(int*);
|
||||
int turnCardsValue(int*);
|
||||
|
||||
+4
-4
@@ -755,22 +755,22 @@ Log::debugMode_getStartDealerPosition(unsigned* dealerPosition)
|
||||
}
|
||||
|
||||
void
|
||||
Log::debugMode_getBoardCards(int *tempBoardArray, int handID)
|
||||
Log::debugMode_getBoardCards(int *boardCards, int handID)
|
||||
{
|
||||
if(debug_mode) {
|
||||
if((unsigned)handID <= sizeof(debug_mode_boardCards)/sizeof(unsigned)/5) {
|
||||
for(int i=0; i<5; i++) tempBoardArray[i] = debug_mode_boardCards[handID-1][i];
|
||||
for(int i=0; i<5; i++) boardCards[i] = debug_mode_boardCards[handID-1][i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Log::debugMode_getPlayerCards(int *tempPlayerArray, int handID, int seatID)
|
||||
Log::debugMode_getPlayerCards(int *playerCards, int handID, int seatID)
|
||||
{
|
||||
if(debug_mode) {
|
||||
if((unsigned)handID <= sizeof(debug_mode_playerCards)/sizeof(int)/MAX_NUMBER_OF_PLAYERS/2) {
|
||||
for(int i=0; i<2; i++) {
|
||||
if(debug_mode_playerCards[handID-1][seatID][i]>=0) tempPlayerArray[i] = debug_mode_playerCards[handID-1][seatID][i];
|
||||
if(debug_mode_playerCards[handID-1][seatID][i]>=0) playerCards[i] = debug_mode_playerCards[handID-1][seatID][i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -792,20 +792,20 @@ void gameTableImpl::applySettings(settingsDialogImpl* mySettingsDialog)
|
||||
//refresh board cards if game is running
|
||||
if(myStartWindow->getSession()->getCurrentGame()) {
|
||||
|
||||
int tempBoardCardsArray[5];
|
||||
myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getBoard()->getMyCards(tempBoardCardsArray);
|
||||
int boardCards[5];
|
||||
myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getBoard()->getMyCards(boardCards);
|
||||
GameState currentState = myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getCurrentBeRo()->getMyBeRoID();
|
||||
if(currentState >= GAME_STATE_FLOP && currentState <= GAME_STATE_POST_RIVER)
|
||||
for(int i=0; i<3; i++) {
|
||||
QPixmap card = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempBoardCardsArray[i], 10)+".png"));
|
||||
QPixmap card = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(boardCards[i], 10)+".png"));
|
||||
boardCardsArray[i]->setPixmap(card, false);
|
||||
}
|
||||
if(currentState >= GAME_STATE_TURN && currentState <= GAME_STATE_POST_RIVER) {
|
||||
QPixmap card = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempBoardCardsArray[3], 10)+".png"));
|
||||
QPixmap card = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(boardCards[3], 10)+".png"));
|
||||
boardCardsArray[3]->setPixmap(card, false);
|
||||
}
|
||||
if(currentState == GAME_STATE_RIVER || currentState == GAME_STATE_POST_RIVER) {
|
||||
QPixmap card = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempBoardCardsArray[4], 10)+".png"));
|
||||
QPixmap card = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(boardCards[4], 10)+".png"));
|
||||
boardCardsArray[4]->setPixmap(card, false);
|
||||
}
|
||||
}
|
||||
@@ -1532,10 +1532,10 @@ void gameTableImpl::dealFlopCards3()
|
||||
void gameTableImpl::dealFlopCards4()
|
||||
{
|
||||
|
||||
int tempBoardCardsArray[5];
|
||||
int boardCards[5];
|
||||
|
||||
myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getBoard()->getMyCards(tempBoardCardsArray);
|
||||
QPixmap card = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempBoardCardsArray[0], 10)+".png"));
|
||||
myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getBoard()->getMyCards(boardCards);
|
||||
QPixmap card = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(boardCards[0], 10)+".png"));
|
||||
|
||||
//Config? mit oder ohne Eye-Candy?
|
||||
if(myConfig->readConfigInt("ShowFlipCardsAnimation")) {
|
||||
@@ -1552,9 +1552,9 @@ void gameTableImpl::dealFlopCards4()
|
||||
void gameTableImpl::dealFlopCards5()
|
||||
{
|
||||
|
||||
int tempBoardCardsArray[5];
|
||||
myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getBoard()->getMyCards(tempBoardCardsArray);
|
||||
QPixmap card = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempBoardCardsArray[1], 10)+".png"));
|
||||
int boardCards[5];
|
||||
myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getBoard()->getMyCards(boardCards);
|
||||
QPixmap card = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(boardCards[1], 10)+".png"));
|
||||
|
||||
//Config? mit oder ohne Eye-Candy?
|
||||
if(myConfig->readConfigInt("ShowFlipCardsAnimation")) {
|
||||
@@ -1571,9 +1571,9 @@ void gameTableImpl::dealFlopCards5()
|
||||
void gameTableImpl::dealFlopCards6()
|
||||
{
|
||||
|
||||
int tempBoardCardsArray[5];
|
||||
myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getBoard()->getMyCards(tempBoardCardsArray);
|
||||
QPixmap card = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempBoardCardsArray[2], 10)+".png"));
|
||||
int boardCards[5];
|
||||
myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getBoard()->getMyCards(boardCards);
|
||||
QPixmap card = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(boardCards[2], 10)+".png"));
|
||||
|
||||
//Config? mit oder ohne Eye-Candy?
|
||||
if(myConfig->readConfigInt("ShowFlipCardsAnimation")) {
|
||||
@@ -1615,9 +1615,9 @@ void gameTableImpl::dealTurnCards1()
|
||||
void gameTableImpl::dealTurnCards2()
|
||||
{
|
||||
|
||||
int tempBoardCardsArray[5];
|
||||
myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getBoard()->getMyCards(tempBoardCardsArray);
|
||||
QPixmap card = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempBoardCardsArray[3], 10)+".png"));
|
||||
int boardCards[5];
|
||||
myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getBoard()->getMyCards(boardCards);
|
||||
QPixmap card = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(boardCards[3], 10)+".png"));
|
||||
|
||||
//Config? mit oder ohne Eye-Candy?
|
||||
if(myConfig->readConfigInt("ShowFlipCardsAnimation")) {
|
||||
@@ -1660,9 +1660,9 @@ void gameTableImpl::dealRiverCards1()
|
||||
void gameTableImpl::dealRiverCards2()
|
||||
{
|
||||
|
||||
int tempBoardCardsArray[5];
|
||||
myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getBoard()->getMyCards(tempBoardCardsArray);
|
||||
QPixmap card = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempBoardCardsArray[4], 10)+".png"));
|
||||
int boardCards[5];
|
||||
myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getBoard()->getMyCards(boardCards);
|
||||
QPixmap card = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(boardCards[4], 10)+".png"));
|
||||
|
||||
//Config? mit oder ohne Eye-Candy?
|
||||
if(myConfig->readConfigInt("ShowFlipCardsAnimation")) {
|
||||
|
||||
Reference in New Issue
Block a user