From 19cad8524a95b6518f212d8e776e16c95437a02d Mon Sep 17 00:00:00 2001 From: floty Date: Tue, 6 Mar 2007 00:50:35 +0000 Subject: [PATCH] engine 0.4 rev1 (file access) --- src/engine/local_engine/localplayer.cpp | 81 ++++++++++++++++++++++++- src/engine/local_engine/localplayer.h | 10 ++- 2 files changed, 88 insertions(+), 3 deletions(-) diff --git a/src/engine/local_engine/localplayer.cpp b/src/engine/local_engine/localplayer.cpp index 0093c53a..5d4e3a51 100755 --- a/src/engine/local_engine/localplayer.cpp +++ b/src/engine/local_engine/localplayer.cpp @@ -23,7 +23,7 @@ using namespace std; -LocalPlayer::LocalPlayer(BoardInterface *b, int id, std::string name, int sC, bool aS, int mB) : PlayerInterface(), actualHand(0), actualBoard(b), myCardsValue(0), myID(id), myName(name), myDude(0), myCardsValueInt(0), myCash(sC), mySet(0), myAction(0), myButton(mB), myActiveStatus(aS), myTurn(0), myRoundStartCash(0), myAverageSets(0) +LocalPlayer::LocalPlayer(BoardInterface *b, int id, std::string name, int sC, bool aS, int mB) : PlayerInterface(), actualHand(0), actualBoard(b), myCardsValue(0), myID(id), myName(name), myDude(0), myCardsValueInt(0), myHoleCardsValue(0), myCash(sC), mySet(0), myAction(0), myButton(mB), myActiveStatus(aS), myTurn(0), myRoundStartCash(0), myAverageSets(0) { // myBestHandPosition mit -1 initialisieren int i; @@ -37,6 +37,15 @@ LocalPlayer::LocalPlayer(BoardInterface *b, int id, std::string name, int sC, bo myTool.getRandNumber(3 , 5, 1, &myDude, 0); // cout << "Spieler: " << myID << " Dude: " << myDude << " Cash: " << myCash << " ActiveStatus: " << myActiveStatus << " Button: " << myButton << endl; + // Dude4 zuweisen + int tempArray[4]; + myTool.getRandNumber(0, 14, 4, tempArray, 0); + for(i=0; i<4; i++) { + myDude4 += tempArray[i]; + } + myDude4 = (myDude4/4)-7; + + myCardsValue = new CardsValue; @@ -100,6 +109,76 @@ void LocalPlayer::action() { void LocalPlayer::preflopEngine() { + // Code der HoleCards ermitteln + int handCode; + if(myCards[0]%13 == myCards[1]%13) { + handCode = (myCards[0]%13)*1000 + (myCards[0]%13)*10; + } else { + if(myCards[0]%13 < myCards[1]%13) { + if(myCards[0]/13 == myCards[1]/13) { + handCode = (myCards[0]%13)*1000 + (myCards[1]%13)*10 + 1; + } else { + handCode = (myCards[0]%13)*1000 + (myCards[1]%13)*10; + } + } else { + if(myCards[0]/13 == myCards[1]/13) { + handCode = (myCards[1]%13)*1000 + (myCards[0]%13)*10 + 1; + } else { + handCode = (myCards[1]%13)*1000 + (myCards[0]%13)*10; + } + } + } + + ConfigFile myConfig; + std::string fileName = myConfig.readConfigString("DataDir")+"preflopValues"; + + ifstream fin; + + fin.open(fileName.c_str()); + if(!fin) { + cout << "Es ist nicht möglich " << fileName << " zum lesen zu oeffnen." << endl; + } + + char buffer[50]; + char hand[5]; + int i,j,k; + char preflopValue[8]; + myHoleCardsValue = -1.; + while(fin.getline(buffer,50)) { + for(i=0; i<5; i++) hand[i] = buffer[i]; + if(handCode == atoi(hand)) { + j = 0; + k = 2; + while(buffer[j] != '|' || k < actualHand->getActualQuantityPlayers()) { + if(buffer[j] == '|') k++; + j++; + } + for(k=0; k<8 ; k++) preflopValue[k] = buffer[k+j+1]; + myHoleCardsValue = 100*atof(preflopValue); + break; + } + } + fin.close(); + if(myHoleCardsValue == -1) cout << "ERROR myHoleCardsValue" << endl; + + // Niveaus setzen + // 1. Fold -- Call + myNiveau[0] = 49 - 8*(actualHand->getActualQuantityPlayers() - 2); + // 2. Check -- Bet + myNiveau[1] = 50; + // 3. Call -- Raise + myNiveau[2] = 70; + + +// mySet += myCash; +// myCash = 0; +// myAction = 6; +// if(mySet > actualHand->getPreflop()->getHighestSet()) actualHand->getPreflop()->setHighestSet(mySet); + +// cout << "Spieler " << myID << ": Dude " << myDude4 << "\t Wert " << myHoleCardsValue << "\t Niveau " << myNiveau[0] << " " << myNiveau[1] << " " << myNiveau[2] << " " << endl; + + + // cout << "nextID " << actualHand->getPlayerArray()[(myID+1)%5]->getMyID() << endl; Tools myTool; diff --git a/src/engine/local_engine/localplayer.h b/src/engine/local_engine/localplayer.h index 7ab20c7c..1d333a02 100755 --- a/src/engine/local_engine/localplayer.h +++ b/src/engine/local_engine/localplayer.h @@ -24,8 +24,10 @@ #include "cardsvalue.h" +#include "configfile.h" + #include -#include +#include class CardsValue; @@ -103,12 +105,16 @@ private: int myID; std::string myName; int myDude; + int myDude4; // Laufvariablen - int myCards[2]; int myCardsValueInt; int myBestHandPosition[5]; + double myHoleCardsValue; + int myNiveau[3]; + + int myCards[2]; int myCash; int mySet; int myAction; // 0 = none, 1 = fold, 2 = check, 3 = call, 4 = bet, 5 = raise, 6 = allin