detemine player who need to show their cards at the end of the hand. this version is possibly buggy, because its tested marginal. additionally the lastActionPlayer is determined not correctly so far.

This commit is contained in:
floty
2010-07-22 06:03:11 +00:00
parent e743f0be85
commit aae32164ff
10 changed files with 263 additions and 80 deletions
+2 -2
View File
@@ -58,8 +58,8 @@ public:
virtual void setHighestCardsValue(int theValue) =0;
virtual int getHighestCardsValue() const =0;
virtual void setLastActionPlayer( int theValue ) =0;
virtual int getLastActionPlayer() const =0;
virtual void setLastActionPlayer( unsigned theValue ) =0;
virtual unsigned getLastActionPlayer() const =0;
virtual void setMinimumRaise (int) =0;
virtual int getMinimumRaise() const =0;
+1 -1
View File
@@ -26,7 +26,7 @@
using namespace std;
LocalBeRo::LocalBeRo(HandInterface* hi, int id, unsigned dP, int sB, GameState gS)
: BeRoInterface(), myHand(hi), myBeRoID(gS), myID(id), dealerPosition(dP), smallBlindPosition(0), dealerPositionId(dP), smallBlindPositionId(0), bigBlindPositionId(0), smallBlind(sB), highestSet(0), minimumRaise(2*sB), fullBetRule(false), firstRun(true), firstRunGui(true), firstRound(true), firstHeadsUpRound(true), currentPlayersTurnId(0), firstRoundLastPlayersTurnId(0), logBoardCardsDone(false)
: BeRoInterface(), myHand(hi), myBeRoID(gS), myID(id), dealerPosition(dP), smallBlindPosition(0), dealerPositionId(dP), smallBlindPositionId(0), bigBlindPositionId(0), smallBlind(sB), highestSet(0), minimumRaise(2*sB), fullBetRule(false), firstRun(true), firstRunGui(true), firstRound(true), firstHeadsUpRound(true), currentPlayersTurnId(0), firstRoundLastPlayersTurnId(0), logBoardCardsDone(false), lastActionPlayer(-1)
{
currentPlayersTurnIt = myHand->getRunningPlayerList()->begin();
lastPlayersTurnIt = myHand->getRunningPlayerList()->begin();
+2 -2
View File
@@ -98,8 +98,8 @@ protected:
void setSmallBlind(int theValue) { smallBlind = theValue; }
int getSmallBlind() const { return smallBlind; }
void setLastActionPlayer ( int theValue ) { lastActionPlayer = theValue; }
int getLastActionPlayer() const { return lastActionPlayer; }
void setLastActionPlayer ( unsigned theValue ) { lastActionPlayer = theValue; }
unsigned getLastActionPlayer() const { return lastActionPlayer; }
@@ -73,14 +73,14 @@ void LocalBeRoPostRiver::postRiverRun() {
// }
// }
// Spieler ermitteln, welche die Karten auf jeden Fall umdrehen müssen
getMyHand()->getBoard()->determinePlayerNeedToShowCards();
// Pot-Verteilung
getMyHand()->getBoard()->distributePot();
//Pot auf 0 setzen
getMyHand()->getBoard()->setPot(0);
// Spieler ermitteln, welche die Karten auf jeden Fall umdrehen müssen
getMyHand()->getBoard()->determinePlayerNeedToShowCards();
//starte die Animaionsreihe
getMyHand()->getGuiInterface()->postRiverRunAnimation1();
+164 -26
View File
@@ -239,39 +239,177 @@ void LocalBoard::distributePot() {
void LocalBoard::determinePlayerNeedToShowCards() {
// all winners have to show their cards
playerNeedToShowCards = winners;
// // the player who has done the last action has to show his cards first
// playerNeedToShowCards.push_back(currentHand->getCurrentBeRo()->getLastActionPlayer());
// all winners have to show their cards
// playerNeedToShowCards = winners;
// std::_List_const_iterator<unsigned> it_c;
std::list<int*> level;
// for(it_c=winners.begin(); it_c != winners.end(); it_c++) {
// cout << (*it_c) << endl;
// }
//
// // get position und cardsValue of the player who show his cards first
// PlayerListConstIterator lastActionPlayerIt = currentHand->getActivePlayerIt(currentHand->getCurrentBeRo()->getLastActionPlayer());
// int highestCardsValueInt = (*lastActionPlayerIt)->getMyCardsValueInt();
// cout << "lastActionPlayer" << currentHand->getCurrentBeRo()->getLastActionPlayer() << endl;
//
// // search for more player who have to show their cards (perhaps not all situation are considered yet)
// PlayerListConstIterator it_c;
// for(it_c = ++lastActionPlayerIt; it_c!=activePlayerList->end(); it_c++) {
// if((*it_c)->getMyCardsValueInt() >= highestCardsValueInt) {
// playerNeedToShowCards.push_back((*it_c)->getMyUniqueID());
// highestCardsValueInt = (*it_c)->getMyCardsValueInt();
// int lastActionPlayer = ;
//
// if(lastActionPlayer == -1) {
// lastActionPlayer = 0;
// }
//
//
//
PlayerListConstIterator lastActionPlayerIt;
PlayerListConstIterator it_c;
// search lastActionPlayer
for(it_c = activePlayerList->begin(); it_c != activePlayerList->end(); it_c++) {
// cout << (*it_c)->getMyUniqueID() << ',';
if((*it_c)->getMyUniqueID() == currentHand->getCurrentBeRo()->getLastActionPlayer() && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD) {
lastActionPlayerIt = it_c;
}
}
// cout << endl;
if(it_c == activePlayerList->end()) {
for(it_c = activePlayerList->begin(); it_c != activePlayerList->end(); it_c++) {
if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) {
lastActionPlayerIt = it_c;
break;
}
}
}
// the player who has done the last action has to show his cards first
playerNeedToShowCards.push_back((*lastActionPlayerIt)->getMyUniqueID());
int *level_tmp = new int[2];
// get position und cardsValue of the player who show his cards first
level_tmp[0] = (*lastActionPlayerIt)->getMyCardsValueInt();
level_tmp[1] = (*lastActionPlayerIt)->getMyRoundStartCash()-(*lastActionPlayerIt)->getMyCash();
// level_tmp = {(*lastActionPlayerIt)->getMyCardsValueInt(),(*lastActionPlayerIt)->getMyRoundStartCash()-(*lastActionPlayerIt)->getMyCash()};
// cout << level_tmp[0] << "," << level_tmp[1] << endl;
level.push_back(level_tmp);
std::_List_iterator<int*> level_it;
std::_List_iterator<int*> level_it_tmp;
std::_List_iterator<int*> next_level_it;
// PlayerListConstIterator firstAfterLastActionPlayerIt = lastActionPlayerIt;
// firstAfterLastActionPlayerIt++;
it_c = lastActionPlayerIt;
it_c++;
for(int i = 0; i < activePlayerList->size(); i++) {
if(it_c == activePlayerList->end()) it_c = activePlayerList->begin();
if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) {
// for(it_c = firstAfterLastActionPlayerIt; it_c != lastActionPlayerIt; it_c++) {
// if(it_c == lastActionPlayerIt) {
// break;
// }
// }
for(level_it = level.begin(); level_it != level.end(); level_it++) {
if((*it_c)->getMyCardsValueInt() > (*level_it)[0]) {
next_level_it = level_it;
next_level_it++;
if(next_level_it == level.end()) {
playerNeedToShowCards.push_back((*it_c)->getMyUniqueID());
level_tmp = new int[2];
level_tmp[0] = (*it_c)->getMyCardsValueInt();
level_tmp[1] = (*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash();
level.push_back(level_tmp);
break;
}
} else {
if((*it_c)->getMyCardsValueInt() == (*level_it)[0]) {
next_level_it = level_it;
next_level_it++;
for(level_it_tmp = level.begin(); level_it_tmp != level.end(); level_it_tmp++) {
cout << (*level_it_tmp)[0] << "," << (*level_it_tmp)[1] << endl;
}
if(next_level_it == level.end() || (*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash() > (*next_level_it)[1]) {
playerNeedToShowCards.push_back((*it_c)->getMyUniqueID());
if((*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash() > (*level_it)[1]) {
(*level_it)[1] = (*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash();
}
}
break;
} else {
if((*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash() > (*level_it)[1]) {
playerNeedToShowCards.push_back((*it_c)->getMyUniqueID());
level_tmp = new int(2);
level_tmp[0] = (*it_c)->getMyCardsValueInt();
level_tmp[1] = (*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash();
for(level_it_tmp = level.begin(); level_it_tmp != level.end(); level_it_tmp++) {
cout << (*level_it_tmp)[0] << "," << (*level_it_tmp)[1] << endl;
}
level.insert(level_it,level_tmp);
for(level_it_tmp = level.begin(); level_it_tmp != level.end(); level_it_tmp++) {
cout << (*level_it_tmp)[0] << "," << (*level_it_tmp)[1] << endl;
}
break;
}
}
}
}
}
it_c++;
}
// bool showCards;
// search for more player who have to show their cards (perhaps not all situation are considered yet)
// for(it_c = ++lastActionPlayerIt; it_c!=activePlayerList->end(); it_c++) {
//
// showCards = false;
//
//// if((*it_c)->getMyCardsValueInt() >= highestCardsValueInt) {
//// playerNeedToShowCards.push_back((*it_c)->getMyUniqueID());
//// highestCardsValueInt = (*it_c)->getMyCardsValueInt();
//// }
// }
//
// for(it_c = activePlayerList->begin(); it_c!=lastActionPlayerIt; it_c++) {
// if((*it_c)->getMyCardsValueInt() >= highestCardsValueInt) {
// playerNeedToShowCards.push_back((*it_c)->getMyUniqueID());
// highestCardsValueInt = (*it_c)->getMyCardsValueInt();
// }
//// if((*it_c)->getMyCardsValueInt() >= highestCardsValueInt) {
//// playerNeedToShowCards.push_back((*it_c)->getMyUniqueID());
//// highestCardsValueInt = (*it_c)->getMyCardsValueInt();
//// }
// }
//
// // sort and unique the list
// playerNeedToShowCards.sort();
// playerNeedToShowCards.unique();
//
// for(it_c = activePlayerList->begin(); it_c!=activePlayerList->end(); it_c++) {
// cout << (*it_c)->getMyUniqueID() << '\t';
// }
// cout << endl;
// sort and unique the list
playerNeedToShowCards.sort();
playerNeedToShowCards.unique();
std::_List_iterator<unsigned> playerNeedToShowCardsIt;
for(playerNeedToShowCardsIt = playerNeedToShowCards.begin(); playerNeedToShowCardsIt!=playerNeedToShowCards.end(); playerNeedToShowCardsIt++) {
cout << (*playerNeedToShowCardsIt) << '\t';
}
cout << endl;
}
+52 -25
View File
@@ -118,11 +118,11 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
case 1: {
tempBoardArray[0] = 32;
tempBoardArray[1] = 8;
tempBoardArray[2] = 7;
tempBoardArray[3] = 48;
tempBoardArray[4] = 21;
tempBoardArray[0] = 39;
tempBoardArray[1] = 2;
tempBoardArray[2] = 3;
tempBoardArray[3] = 4;
tempBoardArray[4] = 5;
myBoard->setMyCards(tempBoardArray);
@@ -135,8 +135,8 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
// player0
it = seatsList->begin();
tempPlayerArray[0] = 44;
tempPlayerArray[1] = 10;
tempPlayerArray[0] = 13;
tempPlayerArray[1] = 14;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
@@ -148,8 +148,8 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
// player1
it++;
tempPlayerArray[0] = 31;
tempPlayerArray[1] = 22;
tempPlayerArray[0] = 18;
tempPlayerArray[1] = 17;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
@@ -161,8 +161,8 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
// player2
it++;
tempPlayerArray[0] = 49;
tempPlayerArray[1] = 34;
tempPlayerArray[0] = 26;
tempPlayerArray[1] = 27;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
@@ -174,8 +174,8 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
// player3
it++;
tempPlayerArray[0] = 23;
tempPlayerArray[1] = 1;
tempPlayerArray[0] = 31;
tempPlayerArray[1] = 30;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
@@ -187,8 +187,8 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
// player4
it++;
tempPlayerArray[0] = 36;
tempPlayerArray[1] = 45;
tempPlayerArray[0] = 50;
tempPlayerArray[1] = 51;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
@@ -200,8 +200,8 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
// player5
it++;
tempPlayerArray[0] = 43;
tempPlayerArray[1] = 30;
tempPlayerArray[0] = 25;
tempPlayerArray[1] = 24;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
@@ -213,8 +213,8 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
// player6
it++;
tempPlayerArray[0] = 24;
tempPlayerArray[1] = 6;
tempPlayerArray[0] = 38;
tempPlayerArray[1] = 37;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
@@ -226,8 +226,21 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
// player7
it++;
tempPlayerArray[0] = 31;
tempPlayerArray[1] = 19;
tempPlayerArray[0] = 32;
tempPlayerArray[1] = 33;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
(*it)->setMyCards(tempPlayerArray);
(*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
(*it)->setMyBestHandPosition(temp5Array);
// player8
it++;
tempPlayerArray[0] = 19;
tempPlayerArray[1] = 20;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
@@ -411,14 +424,28 @@ void LocalHand::assignButtons() {
it = getActivePlayerIt( (*dealerPositionIt)->getMyUniqueID() );
if(it != activePlayerList->end() ) {
nextActivePlayerFound = true;
if(activePlayerList->size() > 2) (*it)->setMyButton(2); //small blind normal
else (*it)->setMyButton(3); //big blind in heads up
if(activePlayerList->size() > 2) {
//small blind normal
(*it)->setMyButton(2);
} else {
//big blind in heads up
(*it)->setMyButton(3);
// lastPlayerAction for showing cards
// getCurrentBeRo()->setLastActionPlayer((*it)->getMyUniqueID());
}
it++;
if(it == activePlayerList->end()) it = activePlayerList->begin();
if(activePlayerList->size() > 2) (*it)->setMyButton(3); //big blind normal
else (*it)->setMyButton(2); //small blind in heads up
if(activePlayerList->size() > 2) {
//big blind normal
(*it)->setMyButton(3);
// lastPlayerAction for showing cards
// getCurrentBeRo()->setLastActionPlayer((*it)->getMyUniqueID());
} else {
//small blind in heads up
(*it)->setMyButton(2);
}
break;
}
+1 -1
View File
@@ -97,7 +97,7 @@ private:
BoardInterface *myBoard;
PlayerList seatsList; // all player
PlayerList activePlayerList; // all player who are not folded and not out
PlayerList activePlayerList; // all player who are not out
PlayerList runningPlayerList; // all player who are not folded, not all in and not out
std::vector<boost::shared_ptr<BeRoInterface> > myBeRo;
+34 -16
View File
@@ -861,31 +861,31 @@ LocalPlayer::LocalPlayer(ConfigFile *c, BoardInterface *b, int id, unsigned uniq
switch(myUniqueID) {
case 0: {
myCash=2980;
myCash=1000;
} break;
case 1: {
myCash=2980;
myCash=1000;
} break;
case 2: {
myCash=2980;
myCash=1000;
} break;
case 3: {
myCash=2980;
myCash=2000;
} break;
case 4: {
myCash=2980;
myCash=3000;
} break;
case 5: {
myCash=2980;
myCash=2000;
} break;
case 6: {
myCash=0;
myCash=2100;
} break;
case 7: {
myCash=0;
myCash=500;
} break;
case 8: {
myCash=0;
myCash=1000;
} break;
case 9: {
myCash=0;
@@ -1380,8 +1380,8 @@ void LocalPlayer::preflopEngine() {
case 3: {
switch(currentHand->getMyID()) {
case 1: {
myAction = PLAYER_ACTION_CALL;
// raise = 20;
myAction = PLAYER_ACTION_RAISE;
raise = 2000;
// if(mySet >= 40) {
// myAction = PLAYER_ACTION_CALL;
// }
@@ -1403,8 +1403,8 @@ void LocalPlayer::preflopEngine() {
case 4: {
switch(currentHand->getMyID()) {
case 1: {
myAction = PLAYER_ACTION_CALL;
// raise = 20;
myAction = PLAYER_ACTION_RAISE;
raise = 2000;
// if(mySet > 0) {
// myAction = PLAYER_ACTION_FOLD;
// }
@@ -1425,7 +1425,7 @@ void LocalPlayer::preflopEngine() {
break;
case 5: {
// if(mySet == 0) {
myAction = PLAYER_ACTION_RAISE;
myAction = PLAYER_ACTION_CALL;
raise = 20;
// }
}
@@ -1436,6 +1436,20 @@ void LocalPlayer::preflopEngine() {
// }
}
break;
case 7: {
// if(mySet == 160) {
myAction = PLAYER_ACTION_CALL;
// }
}
break;
case 8: {
// if(mySet == 160) {
myAction = PLAYER_ACTION_CALL;
// }
}
break;
default: {}
}
@@ -2765,8 +2779,8 @@ void LocalPlayer::riverEngine() {
}
}
// lastPlayerAction für Karten umblättern reihenfolge setzrn
currentHand->getCurrentBeRo()->setLastActionPlayer(myID);
// // lastPlayerAction für Karten umblättern reihenfolge setzrn
// currentHand->getCurrentBeRo()->setLastActionPlayer(myUniqueID);
}
@@ -3054,6 +3068,8 @@ void LocalPlayer::evaluation(int bet, int raise) {
mySet = bet;
highestSet = mySet;
}
// lastPlayerAction für Karten umblättern reihenfolge setzrn
currentHand->getCurrentBeRo()->setLastActionPlayer(myUniqueID);
}
break;
// raise
@@ -3096,6 +3112,8 @@ void LocalPlayer::evaluation(int bet, int raise) {
highestSet = mySet;
}
}
// lastPlayerAction für Karten umblättern reihenfolge setzrn
currentHand->getCurrentBeRo()->setLastActionPlayer(myUniqueID);
}
break;
// all in
+2 -2
View File
@@ -50,13 +50,13 @@ ClientBeRo::setHighestCardsValue(int theValue)
}
void
ClientBeRo::setLastActionPlayer ( int theValue )
ClientBeRo::setLastActionPlayer ( unsigned theValue )
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
lastActionPlayer = theValue;
}
int
unsigned
ClientBeRo::getLastActionPlayer() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
+2 -2
View File
@@ -38,8 +38,8 @@ public:
int getHighestCardsValue() const;
void setHighestCardsValue(int theValue);
void setLastActionPlayer ( int theValue );
int getLastActionPlayer() const;
void setLastActionPlayer ( unsigned theValue );
unsigned getLastActionPlayer() const;
void setPlayersTurn(int theValue);
int getPlayersTurn() const;