From d18c44e2e9d6b56a165beccdae668881f78c75ae Mon Sep 17 00:00:00 2001 From: floty Date: Sat, 1 Sep 2007 16:32:36 +0000 Subject: [PATCH] bugfix: inactive player with 0$ all in --- src/engine/local_engine/localbero.cpp | 8 +- src/engine/local_engine/localhand.cpp | 191 +++++++++++------ src/engine/local_engine/localplayer.cpp | 272 ++++++++++++++++++++++-- 3 files changed, 387 insertions(+), 84 deletions(-) diff --git a/src/engine/local_engine/localbero.cpp b/src/engine/local_engine/localbero.cpp index 4478ca26..706f01a2 100644 --- a/src/engine/local_engine/localbero.cpp +++ b/src/engine/local_engine/localbero.cpp @@ -24,6 +24,8 @@ LocalBeRo::LocalBeRo(HandInterface* hi, int id, int qP, int dP, int sB, GameStat if (myHand->getPlayerArray()[i]->getMyButton() == 2) smallBlindPosition = i; } + cout << smallBlindPosition << endl; + } @@ -115,7 +117,7 @@ void LocalBeRo::run() { // naechsten Spieler ermitteln int i; - for(i=0; (igetPlayerArray()[playersTurn]->getMyActiveStatus()) || (myHand->getPlayerArray()[playersTurn]->getMyAction())==1 || (myHand->getPlayerArray()[playersTurn]->getMyAction())==6) || i==0; i++) { + for(i=0; (igetPlayerArray()[playersTurn]->getMyActiveStatus()) == 0 || (myHand->getPlayerArray()[playersTurn]->getMyAction())==1 || (myHand->getPlayerArray()[playersTurn]->getMyAction())==6)) || i==0; i++) { playersTurn = (playersTurn+1)%(MAX_NUMBER_OF_PLAYERS); } firstHeadsUpRound = 0; @@ -138,7 +140,9 @@ void LocalBeRo::run() { myHand->getGuiInterface()->refreshAction(playersTurn,0); // wenn wir letzter aktiver Spieler vor SmallBlind sind, dann flopFirstRound zuende - if(myHand->getPlayerArray()[playersTurn]->getMyID() == activePlayerBeforeSmallBlind) { firstRound = 0; } + // ausnahme bei heads up !!! --> TODO + if(myHand->getPlayerArray()[playersTurn]->getMyID() == activePlayerBeforeSmallBlind && myHand->getActualQuantityPlayers() >= 3) { firstRound = 0; } + if(myHand->getActualQuantityPlayers() < 3 && (myHand->getPlayerArray()[playersTurn]->getMyID() == dealerPosition || myHand->getPlayerArray()[playersTurn]->getMyID() == smallBlindPosition)) { firstRound = 0; } if(playersTurn == 0) { // Wir sind dran diff --git a/src/engine/local_engine/localhand.cpp b/src/engine/local_engine/localhand.cpp index 2e9b4363..203969cb 100755 --- a/src/engine/local_engine/localhand.cpp +++ b/src/engine/local_engine/localhand.cpp @@ -100,81 +100,146 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, BoardI if(DEBUG_MODE) { - if(myID==1) { + int temp5Array[5]; + + switch(myID) { + + case 1: { - int temp5Array[5]; + tempBoardArray[0] = 43; + tempBoardArray[1] = 22; + tempBoardArray[2] = 35; + tempBoardArray[3] = 39; + tempBoardArray[4] = 13; + + myBoard->setMyCards(tempBoardArray); + + tempPlayerAndBoardArray[2] = tempBoardArray[0]; + tempPlayerAndBoardArray[3] = tempBoardArray[1]; + tempPlayerAndBoardArray[4] = tempBoardArray[2]; + tempPlayerAndBoardArray[5] = tempBoardArray[3]; + tempPlayerAndBoardArray[6] = tempBoardArray[4]; - tempBoardArray[0] = 38; - tempBoardArray[1] = 19; - tempBoardArray[2] = 21; - tempBoardArray[3] = 11; - tempBoardArray[4] = 45; + // player0 + + tempPlayerArray[0] = 1; + tempPlayerArray[1] = 9; + tempPlayerAndBoardArray[0] = tempPlayerArray[0]; + tempPlayerAndBoardArray[1] = tempPlayerArray[1]; + + playerArray[0]->setMyCards(tempPlayerArray); + playerArray[0]->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); + + playerArray[0]->setMyBestHandPosition(temp5Array); + + // player1 - myBoard->setMyCards(tempBoardArray); + tempPlayerArray[0] = 3; + tempPlayerArray[1] = 4; + tempPlayerAndBoardArray[0] = tempPlayerArray[0]; + tempPlayerAndBoardArray[1] = tempPlayerArray[1]; + + playerArray[1]->setMyCards(tempPlayerArray); + playerArray[1]->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); + + playerArray[1]->setMyBestHandPosition(temp5Array); + + // player2 - tempPlayerAndBoardArray[2] = tempBoardArray[0]; - tempPlayerAndBoardArray[3] = tempBoardArray[1]; - tempPlayerAndBoardArray[4] = tempBoardArray[2]; - tempPlayerAndBoardArray[5] = tempBoardArray[3]; - tempPlayerAndBoardArray[6] = tempBoardArray[4]; + tempPlayerArray[0] = 7; + tempPlayerArray[1] = 17; + tempPlayerAndBoardArray[0] = tempPlayerArray[0]; + tempPlayerAndBoardArray[1] = tempPlayerArray[1]; + + playerArray[2]->setMyCards(tempPlayerArray); + playerArray[2]->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); + + playerArray[2]->setMyBestHandPosition(temp5Array); - // player0 + // player3 + + tempPlayerArray[0] = 26; + tempPlayerArray[1] = 28; + tempPlayerAndBoardArray[0] = tempPlayerArray[0]; + tempPlayerAndBoardArray[1] = tempPlayerArray[1]; + + playerArray[3]->setMyCards(tempPlayerArray); + playerArray[3]->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); + + playerArray[3]->setMyBestHandPosition(temp5Array); + + } break; + case 2: { - tempPlayerArray[0] = 9; - tempPlayerArray[1] = 14; - tempPlayerAndBoardArray[0] = tempPlayerArray[0]; - tempPlayerAndBoardArray[1] = tempPlayerArray[1]; + tempBoardArray[0] = 32; + tempBoardArray[1] = 26; + tempBoardArray[2] = 28; + tempBoardArray[3] = 38; + tempBoardArray[4] = 7; + + myBoard->setMyCards(tempBoardArray); + + tempPlayerAndBoardArray[2] = tempBoardArray[0]; + tempPlayerAndBoardArray[3] = tempBoardArray[1]; + tempPlayerAndBoardArray[4] = tempBoardArray[2]; + tempPlayerAndBoardArray[5] = tempBoardArray[3]; + tempPlayerAndBoardArray[6] = tempBoardArray[4]; - playerArray[0]->setMyCards(tempPlayerArray); - playerArray[0]->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); + // player0 + + tempPlayerArray[0] = 45; + tempPlayerArray[1] = 35; + tempPlayerAndBoardArray[0] = tempPlayerArray[0]; + tempPlayerAndBoardArray[1] = tempPlayerArray[1]; + + playerArray[0]->setMyCards(tempPlayerArray); + playerArray[0]->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); + + playerArray[0]->setMyBestHandPosition(temp5Array); + + // player1 - playerArray[0]->setMyBestHandPosition(temp5Array); - - // for(i=0; i<5; i++) { - // cout << temp5Array[i] << " "; - // } - // cout << endl; - - // player1 - - tempPlayerArray[0] = 44; - tempPlayerArray[1] = 27; - tempPlayerAndBoardArray[0] = tempPlayerArray[0]; - tempPlayerAndBoardArray[1] = tempPlayerArray[1]; - - playerArray[1]->setMyCards(tempPlayerArray); - playerArray[1]->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); - - playerArray[1]->setMyBestHandPosition(temp5Array); - - // player2 - - tempPlayerArray[0] = 51; - tempPlayerArray[1] = 22; - tempPlayerAndBoardArray[0] = tempPlayerArray[0]; - tempPlayerAndBoardArray[1] = tempPlayerArray[1]; - - playerArray[2]->setMyCards(tempPlayerArray); - playerArray[2]->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); - - playerArray[2]->setMyBestHandPosition(temp5Array); - -// tempPlayerArray[0] = 19; -// tempPlayerArray[1] = 51; -// tempPlayerAndBoardArray[0] = tempPlayerArray[0]; -// tempPlayerAndBoardArray[1] = tempPlayerArray[1]; - -// playerArray[3]->setMyCards(tempPlayerArray); -// playerArray[3]->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); + tempPlayerArray[0] = 34; + tempPlayerArray[1] = 39; + tempPlayerAndBoardArray[0] = tempPlayerArray[0]; + tempPlayerAndBoardArray[1] = tempPlayerArray[1]; + + playerArray[1]->setMyCards(tempPlayerArray); + playerArray[1]->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); + + playerArray[1]->setMyBestHandPosition(temp5Array); + +// // player2 // -// playerArray[3]->setMyBestHandPosition(temp5Array); - - // for(i=0; i<4; i++) { - // cout << i << ": " << playerArray[i]->getMyCardsValueInt() << endl; - // } +// tempPlayerArray[0] = 7; +// tempPlayerArray[1] = 17; +// tempPlayerAndBoardArray[0] = tempPlayerArray[0]; +// tempPlayerAndBoardArray[1] = tempPlayerArray[1]; +// +// playerArray[2]->setMyCards(tempPlayerArray); +// playerArray[2]->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); +// +// playerArray[2]->setMyBestHandPosition(temp5Array); +// +// // player3 +// +// tempPlayerArray[0] = 26; +// tempPlayerArray[1] = 28; +// tempPlayerAndBoardArray[0] = tempPlayerArray[0]; +// tempPlayerAndBoardArray[1] = tempPlayerArray[1]; +// +// playerArray[3]->setMyCards(tempPlayerArray); +// playerArray[3]->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); +// +// playerArray[3]->setMyBestHandPosition(temp5Array); + + } break; + default: {} } + + } // ---------------------------------------- diff --git a/src/engine/local_engine/localplayer.cpp b/src/engine/local_engine/localplayer.cpp index d943cbc7..a20c5acd 100755 --- a/src/engine/local_engine/localplayer.cpp +++ b/src/engine/local_engine/localplayer.cpp @@ -36,17 +36,17 @@ LocalPlayer::LocalPlayer(ConfigFile *c, BoardInterface *b, int id, unsigned uniq if(myID==0) { // myActiveStatus=0; -// myCash=570; + myCash=11980; } if(myID==1) { -// myCash=2730; + myCash=4505; } if(myID==2) { -// myCash=5970; + myCash=9985; } if(myID==3) { -// myCash=2730; + myCash=8530; } } @@ -347,12 +347,12 @@ void LocalPlayer::preflopEngine() { switch(actualHand->getMyID()) { case 1: { - myAction = PLAYER_ACTION_FOLD; + myAction = PLAYER_ACTION_CALL; } break; case 2: { myAction = PLAYER_ACTION_RAISE; - raise = 70; + raise = 25; } break; default: { @@ -365,19 +365,19 @@ void LocalPlayer::preflopEngine() { switch(actualHand->getMyID()) { case 1: { - myAction = PLAYER_ACTION_RAISE; - raise = 20; - if(mySet >= 40) { - myAction = PLAYER_ACTION_CALL; - } + myAction = PLAYER_ACTION_CALL; +// raise = 20; +// if(mySet >= 40) { +// myAction = PLAYER_ACTION_CALL; +// } } break; case 2: { - myAction = PLAYER_ACTION_RAISE; - raise = 50; - if(mySet >= 70) { - myAction = PLAYER_ACTION_CALL; - } +// myAction = PLAYER_ACTION_RAISE; +// raise = 50; +// if(mySet >= 70) { +// myAction = PLAYER_ACTION_CALL; +// } } break; default: { @@ -386,7 +386,7 @@ void LocalPlayer::preflopEngine() { } break; - case 3: { myAction = PLAYER_ACTION_FOLD; } + case 3: { myAction = PLAYER_ACTION_CALL; } break; default: {} } @@ -623,9 +623,82 @@ void LocalPlayer::flopEngine() { } -// cout << myID << ": Dude " << myDude4 << "\t Wert " << myOdds << "\t Niveau " << myNiveau[0] << " " << myNiveau[1] << " " << myNiveau[2] << endl; + if(DEBUG_MODE) { + switch(myID) { + case 0: { + } break; + case 1: { -// cout << myID << ": " << myOdds << " - " << myNiveau[0] << " " << myNiveau[1] << " " << myNiveau[2] << " - " << "Bluff: " << sBluffStatus << endl; + switch(actualHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_CHECK; + if(actualHand->getCurrentBeRo()->getHighestSet() > 0) { + myAction = PLAYER_ACTION_CALL; + } + } break; + case 2: { +// myAction = PLAYER_ACTION_BET; +// raise = 25; + } break; + default: { + } + } + } break; + case 2: { + + switch(actualHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_BET; + bet = 10; +// raise = 20; +// if(mySet >= 40) { +// myAction = PLAYER_ACTION_CALL; +// } + } + break; + case 2: { +// myAction = PLAYER_ACTION_RAISE; +// raise = 50; +// if(mySet >= 70) { +// myAction = PLAYER_ACTION_CALL; +// } + } + break; + default: { + } + } + + } + break; + case 3: { + switch(actualHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_CHECK; + if(actualHand->getCurrentBeRo()->getHighestSet() > 0) { + myAction = PLAYER_ACTION_CALL; + } + } + break; + case 2: { +// myAction = PLAYER_ACTION_RAISE; +// raise = 50; +// if(mySet >= 70) { +// myAction = PLAYER_ACTION_CALL; +// } + } + break; + default: { + } + } + + + } + break; + default: {} + } + + + } evaluation(bet, raise); @@ -1116,6 +1189,89 @@ void LocalPlayer::turnEngine() { // cout << "myAction: " << myAction << endl; + if(DEBUG_MODE) { + + switch(myID) { + + case 0: { + } + break; + case 1: { + + switch(actualHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_CALL; + if(actualHand->getCurrentBeRo()->getHighestSet() > 100) { + myAction = PLAYER_ACTION_FOLD; + } + } + break; + case 2: { +// myAction = PLAYER_ACTION_BET; +// raise = 25; + } + break; + default: { + } + } + } + break; + case 2: { + + switch(actualHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_RAISE; + raise = 40; + if(actualHand->getCurrentBeRo()->getHighestSet() > 100) { + myAction = PLAYER_ACTION_CALL; + } + } + break; + case 2: { +// myAction = PLAYER_ACTION_RAISE; +// raise = 50; +// if(mySet >= 70) { +// myAction = PLAYER_ACTION_CALL; +// } + } + break; + default: { + } + } + + } + break; + case 3: { + switch(actualHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_BET; + bet = 10; + if(actualHand->getCurrentBeRo()->getHighestSet() > 0) { + myAction = PLAYER_ACTION_CALL; + } + } + break; + case 2: { +// myAction = PLAYER_ACTION_RAISE; +// raise = 50; +// if(mySet >= 70) { +// myAction = PLAYER_ACTION_CALL; +// } + } + break; + default: { + } + } + + + } + break; + default: {} + } + + + } + evaluation(bet, raise); } @@ -1345,6 +1501,84 @@ void LocalPlayer::riverEngine() { // cout << myID << ": " << myOdds << " - " << myNiveau[0] << " " << myNiveau[1] << " " << myNiveau[2] << " - " << "Bluff: " << sBluffStatus << endl; + if(DEBUG_MODE) { + switch(myID) { + case 0: { + } break; + case 1: { + + switch(actualHand->getMyID()) { + case 1: { +// myAction = PLAYER_ACTION_CALL; +// if(actualHand->getCurrentBeRo()->getHighestSet() > 100) { +// myAction = PLAYER_ACTION_FOLD; +// } + } break; + case 2: { +// myAction = PLAYER_ACTION_BET; +// raise = 25; + } break; + default: { + } + } + } break; + case 2: { + + switch(actualHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_CALL; +// raise = 40; +// if(actualHand->getCurrentBeRo()->getHighestSet() > 100) { +// myAction = PLAYER_ACTION_CALL; +// } + } + break; + case 2: { +// myAction = PLAYER_ACTION_RAISE; +// raise = 50; +// if(mySet >= 70) { +// myAction = PLAYER_ACTION_CALL; +// } + } + break; + default: { + } + } + + } + break; + case 3: { + switch(actualHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_BET; + bet = 120; + if(actualHand->getCurrentBeRo()->getHighestSet() > 0) { + myAction = PLAYER_ACTION_RAISE; + raise = 10000; + } + } + break; + case 2: { +// myAction = PLAYER_ACTION_RAISE; +// raise = 50; +// if(mySet >= 70) { +// myAction = PLAYER_ACTION_CALL; +// } + } + break; + default: { + } + } + + + } + break; + default: {} + } + + + } + evaluation(bet, raise);