adds activePlayerList and runningPlayerList (XIII) - BUGGY!!! - last sable rev866

This commit is contained in:
doitux
2007-09-26 10:13:10 +00:00
parent 8ac5673c00
commit 6c19233c18
10 changed files with 96 additions and 75 deletions
+1
View File
@@ -29,6 +29,7 @@ class HandInterface;
typedef boost::shared_ptr<std::list<boost::shared_ptr<PlayerInterface> > > PlayerList;
typedef std::list<boost::shared_ptr<PlayerInterface> >::iterator PlayerListIterator;
typedef std::list<boost::shared_ptr<PlayerInterface> >::const_iterator PlayerListConstIterator;
class BoardInterface {
+2 -2
View File
@@ -14,7 +14,7 @@
using namespace std;
LocalBeRo::LocalBeRo(HandInterface* hi, int id, int dP, int sB, GameState gS)
: BeRoInterface(), myHand(hi), myBeRoID(gS), myID(id), dealerPosition(dP), smallBlindPosition(0), smallBlind(sB), highestSet(false), minimumRaise(2*sB), firstRun(true), firstRound(true), firstHeadsUpRound(true), logBoardCardsDone(false)
: BeRoInterface(), myHand(hi), myBeRoID(gS), myID(id), dealerPosition(dP), smallBlindPosition(0), smallBlind(sB), highestSet(false), minimumRaise(2*sB), firstRun(true), firstRound(true), firstHeadsUpRound(true), currentPlayersTurn(0), firstRoundLastPlayersTurn(0), logBoardCardsDone(false)
{
currentPlayersTurnIt = myHand->getRunningPlayerList()->begin();
lastPlayersTurnIt = myHand->getRunningPlayerList()->begin();
@@ -38,7 +38,7 @@ void LocalBeRo::nextPlayer() {
// myHand->getPlayerArray()[playersTurn]->action();
cout << "playerID in nextPlayer(): " << (*currentPlayersTurnIt)->getMyID() << endl;
// cout << "playerID in nextPlayer(): " << (*currentPlayersTurnIt)->getMyID() << endl;
(*currentPlayersTurnIt)->action();
+9
View File
@@ -53,6 +53,12 @@ protected:
void setPlayersTurn(int theValue) { playersTurn = theValue; }
int getPlayersTurn() const { return playersTurn;}
void setCurrentPlayersTurn(unsigned theValue) { currentPlayersTurn = theValue; }
unsigned getCurrentPlayersTurn() const { return currentPlayersTurn;}
void setFirstRoundLastPlayersTurn(unsigned theValue) { firstRoundLastPlayersTurn = theValue; }
unsigned getFirstRoundLastPlayersTurn() const { return firstRoundLastPlayersTurn;}
void setCurrentPlayersTurnIt(PlayerListIterator theValue) { currentPlayersTurnIt = theValue; }
PlayerListIterator getCurrentPlayersTurnIt() const { return currentPlayersTurnIt; }
@@ -98,6 +104,9 @@ private:
PlayerListIterator currentPlayersTurnIt; // iterator for runningPlayerList
PlayerListIterator lastPlayersTurnIt; // iterator for runningPlayerList
unsigned currentPlayersTurn;
unsigned firstRoundLastPlayersTurn;
bool logBoardCardsDone;
int lastActionPlayer;
+11 -2
View File
@@ -24,8 +24,10 @@
using namespace std;
LocalBeRoPreflop::LocalBeRoPreflop(HandInterface* hi, int id, int dP, int sB) : LocalBeRo(hi, id, dP, sB, GAME_STATE_PREFLOP)
LocalBeRoPreflop::LocalBeRoPreflop(HandInterface* hi, int id, int dP, int sB) : LocalBeRo(hi, id, dP, sB, GAME_STATE_PREFLOP), bigBlindPosition(0)
{
PlayerListConstIterator it_c;
setHighestSet(2*getSmallBlind());
// determine bigBlindPosition
@@ -33,6 +35,13 @@ LocalBeRoPreflop::LocalBeRoPreflop(HandInterface* hi, int id, int dP, int sB) :
if((*bigBlindPositionIt)->getMyButton() == BUTTON_BIG_BLIND) break;
}
for(it_c=getMyHand()->getActivePlayerList()->begin(); it_c!=getMyHand()->getActivePlayerList()->end(); it_c++) {
if((*it_c)->getMyButton() == BUTTON_BIG_BLIND) {
bigBlindPosition = (*it_c)->getMyUniqueID();
break;
};
}
// search player in runningPlayerList before first action player -> run() determine next player who will do first action
PlayerListIterator it_1, it_2, it_3;
@@ -80,7 +89,7 @@ LocalBeRoPreflop::LocalBeRoPreflop(HandInterface* hi, int id, int dP, int sB) :
setCurrentPlayersTurnIt(getLastPlayersTurnIt());
cout << "playerID constructor preflopRun(): " << (*(getCurrentPlayersTurnIt()))->getMyID() << endl;
// cout << "playerID constructor beropreflop: " << (*(getCurrentPlayersTurnIt()))->getMyID() << endl;
/////////////// testing
@@ -35,6 +35,7 @@ public:
private:
PlayerListIterator bigBlindPositionIt; // iterator for activePlayerList
unsigned bigBlindPosition;
};
#endif
+51 -56
View File
@@ -27,12 +27,12 @@
using namespace std;
LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, std::vector<boost::shared_ptr<PlayerInterface> > sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC)
: myFactory(f), myGui(g), myBoard(b), playerArray(sl), activePlayerList(apl), runningPlayerList(rpl), myBeRo(0), myID(id), startQuantityPlayers(sP), dealerPosition(dP), actualRound(0), smallBlind(sB), startCash(sC), lastPlayersTurn(0), allInCondition(0),
: myFactory(f), myGui(g), myBoard(b), playerArray(sl), activePlayerList(apl), runningPlayerList(rpl), myBeRo(0), myID(id), startQuantityPlayers(sP), dealerPosition(dP), actualRound(0), smallBlind(sB), startCash(sC), lastPlayersTurn(0), allInCondition(false),
cardsShown(false), bettingRoundsPlayed(0)
{
int i, j, k;
PlayerListIterator it;
PlayerListConstIterator it_c;
CardsValue myCardsValue;
@@ -46,10 +46,10 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
// roundStartCashArray fllen
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
playerArray[i]->setMyRoundStartCash(playerArray[i]->getMyCash());
}
// for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
// playerArray[i]->setMyRoundStartCash(playerArray[i]->getMyCash());
// }
// Karten generieren und Board sowie Player zuweisen
int *cardsArray = new int[2*activePlayerList->size()+5];
Tools::getRandNumber(0, 51, 2*activePlayerList->size()+5, cardsArray, 1);
@@ -65,18 +65,19 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
k = 0;
myBoard->setMyCards(tempBoardArray);
for(it=activePlayerList->begin(); it!=activePlayerList->end(); it++, k++) {
for(it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); it_c++, k++) {
(*it)->getMyBestHandPosition(bestHandPos);
(*it_c)->getMyBestHandPosition(bestHandPos);
for(j=0; j<2; j++) {
tempPlayerArray[j] = cardsArray[2*k+j+5];
tempPlayerAndBoardArray[j] = cardsArray[2*k+j+5];
}
(*it)->setMyCards(tempPlayerArray);
(*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray, bestHandPos));
(*it)->setMyBestHandPosition(bestHandPos);
(*it_c)->setMyCards(tempPlayerArray);
(*it_c)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray, bestHandPos));
(*it_c)->setMyBestHandPosition(bestHandPos);
(*it_c)->setMyRoundStartCash((*it_c)->getMyCash());
// myBestHandPosition auf Fehler ueberpruefen
for(j=0; j<5; j++) {
@@ -86,10 +87,10 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
}
// sBluff für alle aktiver Spieler außer human player setzen --> TODO for ai-player in internet
if((*it)->getMyID() != 0) {
if((*it_c)->getMyID() != 0) {
Tools::getRandNumber(1,100,1,&sBluff,0);
(*it)->setSBluff(sBluff);
(*it)->setSBluffStatus(0);
(*it_c)->setSBluff(sBluff);
(*it_c)->setSBluffStatus(0);
}
}
@@ -99,7 +100,7 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
if(DEBUG_MODE) {
int temp5Array[5];
// int temp5Array[5];
switch(myID) {
@@ -285,7 +286,7 @@ void LocalHand::start() {
void LocalHand::assignButtons() {
int i,j;
PlayerListIterator it;
PlayerListConstIterator it_c;
// alle Buttons loeschen
for (i=0; i<MAX_NUMBER_OF_PLAYERS; i++) { playerArray[i]->setMyButton(0); }
@@ -317,50 +318,43 @@ void LocalHand::assignButtons() {
}
//do sets --> TODO switch?
for (it=runningPlayerList->begin(); it!=runningPlayerList->end(); ) {
for (it_c=runningPlayerList->begin(); it_c!=runningPlayerList->end(); it_c++) {
//small blind
if((*it)->getMyButton() == 2) {
if((*it_c)->getMyButton() == 2) {
// All in ?
if((*it)->getMyCash() <= smallBlind) {
if((*it_c)->getMyCash() <= smallBlind) {
(*it)->setMySet((*it)->getMyCash());
(*it_c)->setMySet((*it_c)->getMyCash());
// 1 to do not log this
(*it)->setMyAction(6,1);
(*it_c)->setMyAction(6,1);
// delete this player from runningPlayerList
it = runningPlayerList->erase(it);
// it_c = runningPlayerList->erase(it_c);
}
else {
(*it)->setMySet(smallBlind);
it++;
(*it_c)->setMySet(smallBlind);
}
} else {
//big blind
if((*it)->getMyButton() == 3) {
// all in ?
if((*it)->getMyCash() <= 2*smallBlind) {
(*it)->setMySet((*it)->getMyCash());
// 1 to do not log this
(*it)->setMyAction(6,1);
// delete this player from runningPlayerList
it = runningPlayerList->erase(it);
}
else {
(*it)->setMySet(2*smallBlind);
it++;
}
} else {
it++;
}
}
//big blind
if((*it_c)->getMyButton() == 3) {
// all in ?
if((*it_c)->getMyCash() <= 2*smallBlind) {
(*it_c)->setMySet((*it_c)->getMyCash());
// 1 to do not log this
(*it_c)->setMyAction(6,1);
// delete this player from runningPlayerList
// it_c = runningPlayerList->erase(it_c);
}
else {
(*it_c)->setMySet(2*smallBlind);
}
}
}
}
@@ -370,16 +364,17 @@ void LocalHand::switchRounds() {
// cout << "playerID begin switchRounds(): " << getCurrentBeRo()->get
int i;
PlayerListIterator it, it_1;
PlayerListIterator it;
PlayerListConstIterator it_c;
// refresh runningPlayerList
for(it=runningPlayerList->begin(); it!=runningPlayerList->end(); ) {
if((*it)->getMyAction() == 1 || (*it)->getMyAction() == 6) {
it = runningPlayerList->erase(it);
it_1 = it;
if(it_1 == runningPlayerList->begin()) it_1 = runningPlayerList->end();
it_1--;
getCurrentBeRo()->setCurrentPlayersTurnIt(it_1);
// it_1 = it;
// if(it_1 == runningPlayerList->begin()) it_1 = runningPlayerList->end();
// it_1--;
// getCurrentBeRo()->setCurrentPlayersTurnIt(it_1);
} else {
it++;
}
@@ -387,14 +382,14 @@ void LocalHand::switchRounds() {
// Anzahl der Spieler ermitteln, welche All In sind
int allInPlayersCounter = 0;
for (it=activePlayerList->begin(); it!=activePlayerList->end(); it++) {
if ((*it)->getMyAction() == 6) allInPlayersCounter++;
for (it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); it_c++) {
if ((*it_c)->getMyAction() == 6) allInPlayersCounter++;
}
// TODO -> runningPlayerList.size()
int nonFoldPlayerCounter = 0;
for (it=activePlayerList->begin(); it!=activePlayerList->end(); it++) {
if ((*it)->getMyAction() != 1) nonFoldPlayerCounter++;
for (it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); it_c++) {
if ((*it_c)->getMyAction() != 1) nonFoldPlayerCounter++;
}
//wenn nur noch einer nicht-folded dann gleich den Pot verteilen
+1 -1
View File
@@ -976,7 +976,7 @@ void LocalPlayer::action() {
actualHand->getGuiInterface()->logPlayerActionMsg(myName, myAction, mySet);
actualHand->getGuiInterface()->nextPlayerAnimation();
cout << "playerID in action(): " << (*(actualHand->getCurrentBeRo()->getCurrentPlayersTurnIt()))->getMyID() << endl;
// cout << "playerID in action(): " << (*(actualHand->getCurrentBeRo()->getCurrentPlayersTurnIt()))->getMyID() << endl;
}