Files
pokerth/src/engine/local_engine/localplayer.cpp
T

1573 lines
47 KiB
C++
Raw Normal View History

2007-01-13 02:40:33 +00:00
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "localplayer.h"
#include "localhand.h"
using namespace std;
2007-03-09 03:53:39 +00:00
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), myDude4(0), myCardsValueInt(0), myHoleCardsValue(0), myCash(sC), mySet(0), myAction(0), myButton(mB), myActiveStatus(aS), myTurn(0), myRoundStartCash(0)
2007-01-13 02:40:33 +00:00
{
2007-01-28 00:17:49 +00:00
// myBestHandPosition mit -1 initialisieren
int i;
for(i=0; i<5; i++) {
myBestHandPosition[i] = -1;
}
2007-03-09 03:53:39 +00:00
// myAverageSets initialisieren
for(i=0; i<4; i++) {
myAverageSets[i] = 0;
}
2007-01-13 02:40:33 +00:00
Tools myTool;
// Dude zuweisen
myTool.getRandNumber(3 , 5, 1, &myDude, 0);
// cout << "Spieler: " << myID << " Dude: " << myDude << " Cash: " << myCash << " ActiveStatus: " << myActiveStatus << " Button: " << myButton << endl;
2007-03-06 00:50:35 +00:00
// Dude4 zuweisen
2007-03-09 03:53:39 +00:00
int interval = 7;
int count = 4;
2007-03-06 00:50:35 +00:00
int tempArray[4];
2007-03-09 03:53:39 +00:00
myTool.getRandNumber(0, 2*interval, count, tempArray, 0);
for(i=0; i<count; i++) {
2007-03-06 00:50:35 +00:00
myDude4 += tempArray[i];
}
2007-03-09 03:53:39 +00:00
myDude4 = (myDude4/count)-interval;
2007-03-06 00:50:35 +00:00
2007-01-13 02:40:33 +00:00
myCardsValue = new CardsValue;
2007-01-22 22:25:58 +00:00
2007-01-13 02:40:33 +00:00
}
LocalPlayer::~LocalPlayer()
{
}
2007-01-14 12:40:30 +00:00
void LocalPlayer::setHand(HandInterface* br) { actualHand = br; }
2007-01-13 02:40:33 +00:00
void LocalPlayer::action() {
switch(actualHand->getActualRound()) {
case 0: {
preflopEngine();
actualBoard->collectSets();
2007-01-13 14:27:56 +00:00
actualHand->getGuiInterface()->refreshPot();
2007-01-13 02:40:33 +00:00
} break;
case 1: {
flopEngine();
actualBoard->collectSets();
2007-01-13 14:27:56 +00:00
actualHand->getGuiInterface()->refreshPot();
2007-01-13 02:40:33 +00:00
} break;
case 2: {
turnEngine();
actualBoard->collectSets();
2007-01-13 14:27:56 +00:00
actualHand->getGuiInterface()->refreshPot();
2007-01-13 02:40:33 +00:00
} break;
case 3: {
riverEngine();
actualBoard->collectSets();
2007-01-13 14:27:56 +00:00
actualHand->getGuiInterface()->refreshPot();
2007-01-13 02:40:33 +00:00
} break;
default: {}
}
myTurn = 0;
// cout << "jetzt" << endl;
2007-02-04 00:34:44 +00:00
actualHand->getGuiInterface()->logPlayerActionMsg(myName, myAction, mySet);
2007-01-13 02:40:33 +00:00
actualHand->getGuiInterface()->nextPlayerAnimation();
}
void LocalPlayer::preflopEngine() {
2007-03-06 00:50:35 +00:00
ConfigFile myConfig;
2007-03-09 03:53:39 +00:00
if(myConfig.readConfigInt("EngineVersion")) {
// cout << "Engine 0.3" << endl;
2007-01-13 02:40:33 +00:00
2007-03-09 03:53:39 +00:00
// cout << "nextID " << actualHand->getPlayerArray()[(myID+1)%5]->getMyID() << endl;
Tools myTool;
int raise = 0;
// Bauchgefhl (zufᅵlig)
int tempRand;
myTool.getRandNumber(1,10,1,&tempRand,0);
// bluff, checkbluff
int bluff;
myTool.getRandNumber(1,100,1,&bluff,0);
// cout << "preflop-bluff " << bluff << endl;
// Potential
int potential = 10*(4*(myCardsValue->holeCardsClass(myCards[0], myCards[1]))+1*tempRand)/50-myDude;
int setToHighest = actualHand->getPreflop()->getHighestSet() - mySet;
// temp fr das Vielfache des Small Blind, sodass HighestSet zu hoch ist
int tempFold;
// tempFold = (actualHand->getPlayerArray()[0]->getMyAverageSets())/(8*actualHand->getSmallBlind());
myTool.getRandNumber(2,3,1,&tempFold,0);
// FOLD --> wenn Potential negativ oder HighestSet zu hoch
if( (potential*setToHighest<0 || (setToHighest > tempFold * actualHand->getSmallBlind() && potential<1) || (setToHighest > 2 * tempFold * actualHand->getSmallBlind() && potential<2) || (setToHighest > 4 * tempFold * actualHand->getSmallBlind() && potential<3) || (setToHighest > 10 * tempFold * actualHand->getSmallBlind() && potential<4)) && myCardsValue->holeCardsClass(myCards[0], myCards[1]) < 9 && bluff > 15) {
myAction=1;
}
else {
// RAISE --> wenn hohes Potential
if(potential >= 4 && 6 * actualHand->getSmallBlind() >= actualHand->getPreflop()->getHighestSet() || bluff <= 6) {
// extrem hohes Potential --> groᅵr Raise
if(potential>=6 || bluff <= 2) {
// bluff - raise
if(bluff <=2 && 4 * actualHand->getSmallBlind() > actualHand->getPreflop()->getHighestSet()) {
raise = 3 * actualHand->getPreflop()->getHighestSet();
2007-01-13 02:40:33 +00:00
}
else {
2007-03-09 03:53:39 +00:00
// bluff - call
if(bluff >= 98) {
// All In
if(actualHand->getPreflop()->getHighestSet() >= myCash) {
mySet += myCash;
myCash = 0;
myAction = 6;
}
// sonst
else {
myCash = myCash - actualHand->getPreflop()->getHighestSet() + mySet;
mySet = actualHand->getPreflop()->getHighestSet();
myAction = 3;
}
} else {
// doch nich raisen, sondern nur checken, weil highestSets bereits sehr hoch !!!
if(! (4 * actualHand->getSmallBlind() > actualHand->getPreflop()->getHighestSet())) {
// All In
if(actualHand->getPreflop()->getHighestSet() >= myCash) {
mySet += myCash;
myCash = 0;
myAction = 6;
}
// sonst
else {
myCash = myCash - actualHand->getPreflop()->getHighestSet() + mySet;
mySet = actualHand->getPreflop()->getHighestSet();
myAction = 3;
}
}
else raise = (potential - 4 ) * 2 * actualHand->getPreflop()->getHighestSet();
}
}
}
// hohes Potential --> gemäßigter Raise
else {
// bluff - raise
if(bluff <= 6 && 4 * actualHand->getSmallBlind() > actualHand->getPreflop()->getHighestSet()) {
raise = 2*actualHand->getPreflop()->getHighestSet();
}
else {
// bluff - call
if(bluff >= 93) {
2007-01-13 02:40:33 +00:00
// All In
if(actualHand->getPreflop()->getHighestSet() >= myCash) {
mySet += myCash;
myCash = 0;
myAction = 6;
}
// sonst
else {
myCash = myCash - actualHand->getPreflop()->getHighestSet() + mySet;
mySet = actualHand->getPreflop()->getHighestSet();
myAction = 3;
}
}
2007-03-09 03:53:39 +00:00
else {
// doch nich raisen, sondern nur checken, weil highestSets bereits sehr hoch !!!
if(! (4 * actualHand->getSmallBlind() > actualHand->getPreflop()->getHighestSet())) {
// All In
if(actualHand->getPreflop()->getHighestSet() >= myCash) {
mySet += myCash;
myCash = 0;
myAction = 6;
}
// sonst
else {
myCash = myCash - actualHand->getPreflop()->getHighestSet() + mySet;
mySet = actualHand->getPreflop()->getHighestSet();
myAction = 3;
}
}
else raise = (potential - 3 ) * actualHand->getPreflop()->getHighestSet();
}
}
}
if (raise > 0) {
// All In
if(actualHand->getPreflop()->getHighestSet() + raise >= myCash) {
mySet += myCash;
myCash = 0;
myAction = 6;
if(mySet > actualHand->getPreflop()->getHighestSet()) actualHand->getPreflop()->setHighestSet(mySet);
}
// sonst
else {
myCash = myCash + mySet - actualHand->getPreflop()->getHighestSet() - raise;
mySet = actualHand->getPreflop()->getHighestSet() + raise;
actualHand->getPreflop()->setHighestSet(mySet);
myAction = 5;
2007-01-13 02:40:33 +00:00
}
}
}
2007-03-09 03:53:39 +00:00
//CHECK und CALL
else {
// CHECK --> wenn alle Sets glieich bei BigBlind und nich zu hohem Potential
if(mySet == actualHand->getPreflop()->getHighestSet()) {
myAction = 2;
}
// CALL --> bei normalen Potential
else {
// All In
if(actualHand->getPreflop()->getHighestSet() >= myCash) {
2007-01-13 02:40:33 +00:00
2007-03-09 03:53:39 +00:00
mySet += myCash;
myCash = 0;
myAction = 6;
}
// sonst
else {
myCash = myCash - actualHand->getPreflop()->getHighestSet() + mySet;
mySet = actualHand->getPreflop()->getHighestSet();
myAction = 3;
}
}
}
}
2007-01-13 02:40:33 +00:00
2007-03-09 03:53:39 +00:00
}
// ############# ENGINE 0.4 ##################
else {
// cout << "Engine 0.4" << endl;
// 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;
}
}
}
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[6];
hand[5] = '\0';
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 - " << handCode << endl;
int raise = 0;
// Niveaus setzen + Dude + Anzahl Gegenspieler
// 1. Fold -- Call
myNiveau[0] = 40 + myDude4 - 6*(actualHand->getActualQuantityPlayers() - 2);
// 2. Check -- Bet
myNiveau[1] = 50;
// 3. Call -- Raise
myNiveau[2] = 53 + myDude4 - 6*(actualHand->getActualQuantityPlayers() - 2);
// Verhaeltnis Set / Cash
if(myCash/actualHand->getPreflop()->getHighestSet() >= 25) {
myNiveau[0] += (25-myCash/actualHand->getPreflop()->getHighestSet())/10;
} else {
myNiveau[0] += (25-myCash/actualHand->getPreflop()->getHighestSet())/3;
}
// auf Aggresivität des humanPlayers eingehen
int aggValue = ( (50*(actualHand->getPlayerArray()[0]->getMyAverageSets()-6*actualHand->getSmallBlind())) / (actualHand->getStartQuantityPlayers()*actualHand->getStartCash() - 6*actualHand->getSmallBlind()) );
if(aggValue > 0) {
myNiveau[0] -= aggValue;
myNiveau[2] -= aggValue;
}
// cout << "Spieler " << myID << ": Dude " << myDude4 << "\t Wert " << myHoleCardsValue << "\t Niveau " << myNiveau[0] << " " << myNiveau[1] << " " << myNiveau[2] << "\t Agg " << aggValue << " " << endl;
// aktive oder passivie Situation ? -> im preflop nur passiv
// raise (bei hohem Niveau)
if(myHoleCardsValue >= myNiveau[2]) {
// raise-loop unterbinden -> d.h. entweder call oder bei superblatt all in
if(actualHand->getPreflop()->getHighestSet() >= 12*actualHand->getSmallBlind()) {
// all in
if(myHoleCardsValue >= myNiveau[2] + 8) {
raise = myCash;
myAction = 5;
}
// nur call
else {
myAction = 3;
}
// Standard-Raise-Routine
} else {
// raise-Betrag ermitteln
raise = (((int)myHoleCardsValue-myNiveau[2])/2)*2*actualHand->getSmallBlind();
// raise-Betrag zu klein -> mindestens Standard-raise
if(raise == 0) {
raise = actualHand->getPreflop()->getHighestSet()-mySet;
}
myAction = 5;
}
}
else {
// call
if(myHoleCardsValue >= myNiveau[0] || (mySet >= actualHand->getPreflop()->getHighestSet()/2 && myHoleCardsValue >= myNiveau[0]-5)) {
// bigBlind --> check
if(myButton == 3 && mySet == actualHand->getPreflop()->getHighestSet()) myAction = 2;
else myAction = 3;
}
// fold
else {
// bigBlind -> check
if(myButton == 3 && mySet == actualHand->getPreflop()->getHighestSet()) myAction = 2;
else myAction = 1;
}
}
// Auswertung
switch(myAction) {
// none
case 0: {}
break;
// fold
case 1: {}
break;
// check
case 2: {}
break;
// call
case 3: {
// all in
if(actualHand->getPreflop()->getHighestSet() >= myCash) {
mySet += myCash;
myCash = 0;
myAction = 6;
}
// sonst
else {
myCash = myCash - actualHand->getPreflop()->getHighestSet() + mySet;
mySet = actualHand->getPreflop()->getHighestSet();
}
}
break;
// bet
case 4: {}
break;
// raise
case 5: {
// all in
if(actualHand->getPreflop()->getHighestSet() + raise >= myCash) {
2007-01-13 02:40:33 +00:00
mySet += myCash;
myCash = 0;
myAction = 6;
if(mySet > actualHand->getPreflop()->getHighestSet()) actualHand->getPreflop()->setHighestSet(mySet);
}
// sonst
else {
myCash = myCash + mySet - actualHand->getPreflop()->getHighestSet() - raise;
mySet = actualHand->getPreflop()->getHighestSet() + raise;
actualHand->getPreflop()->setHighestSet(mySet);
myAction = 5;
}
}
2007-03-09 03:53:39 +00:00
break;
// all in
case 6: {}
break;
default: {}
2007-01-13 02:40:33 +00:00
}
}
}
void LocalPlayer::flopEngine() {
2007-03-17 21:33:46 +00:00
ConfigFile myConfig;
if(myConfig.readConfigInt("EngineVersion")) {
// cout << "Engine 0.3" << endl;
// Prozent ausrechnen
int i, j, k ,l;
int tempBoardCardsArray[5];
int tempMyCardsArray[7];
int tempOpponentCardsArray[7];
actualBoard->getMyCards(tempBoardCardsArray);
tempMyCardsArray[0] = myCards[0];
tempMyCardsArray[1] = myCards[1];
tempMyCardsArray[2] = tempBoardCardsArray[0];
tempMyCardsArray[3] = tempBoardCardsArray[1];
tempMyCardsArray[4] = tempBoardCardsArray[2];
tempOpponentCardsArray[2] = tempBoardCardsArray[0];
tempOpponentCardsArray[3] = tempBoardCardsArray[1];
tempOpponentCardsArray[4] = tempBoardCardsArray[2];
int tempMyCardsValue;
int tempOpponentCardsValue;
int countAll = 0;
int countMy = 0;
for(i=0; i<49; i++) {
if(i != myCards[0] && i != myCards[1] && i != tempBoardCardsArray[0] && i != tempBoardCardsArray[1] && i != tempBoardCardsArray[2]) {
for(j=i+1; j<50; j++) {
if(j != myCards[0] && j != myCards[1] && j != tempBoardCardsArray[0] && j != tempBoardCardsArray[1] && j != tempBoardCardsArray[2]) {
for(k=j+1; k<51; k++) {
if(k != myCards[0] && k != myCards[1] && k != tempBoardCardsArray[0] && k != tempBoardCardsArray[1] && k != tempBoardCardsArray[2]) {
for(l=k+1; l<52; l++) {
if(l != myCards[0] && l != myCards[1] && l != tempBoardCardsArray[0] && l != tempBoardCardsArray[1] && l != tempBoardCardsArray[2]) {
countAll++;
tempOpponentCardsArray[0] = i;
tempOpponentCardsArray[1] = j;
tempOpponentCardsArray[5] = k;
tempOpponentCardsArray[6] = l;
tempMyCardsArray[5] = k;
tempMyCardsArray[6] = l;
tempMyCardsValue = myCardsValue->cardsValue(tempMyCardsArray,0);
tempOpponentCardsValue = myCardsValue->cardsValue(tempOpponentCardsArray,0);
if(tempMyCardsValue>=tempOpponentCardsValue) countMy++;
}
}
2007-01-13 02:40:33 +00:00
}
}
}
}
}
}
2007-03-17 21:33:46 +00:00
double percent = (countMy*1.0)/(countAll*1.0);
// cout << "Prozent: " << percent << endl;
Tools myTool;
int raise = 0;
// Bauchgefhl (zufᅵlig)
int tempRand;
myTool.getRandNumber((int)(percent*10.)-2,(int)(percent*10.)+2,1,&tempRand,0);
// bluff, checkbluff
int bluff;
myTool.getRandNumber(1,100,1,&bluff,0);
// cout << "flop-bluff " << bluff << endl;
// Potential
int potential = (10*(5*(int)(percent*100.)+10*tempRand*2))/700-myDude;
int setToHighest = actualHand->getFlop()->getHighestSet() - mySet;
// temp fr das Vielfache des Small Blind, sodass HighestSet zu hoch ist
int tempFold;
// tempFold = (actualHand->getPlayerArray()[0]->getMyAverageSets())/(8*actualHand->getSmallBlind());
myTool.getRandNumber(2,3,1,&tempFold,0);
// FOLD --> wenn potential negativ oder HighestSet zu hoch
if(( potential*setToHighest<0 || (setToHighest > tempFold * actualHand->getSmallBlind() && potential<1) || (setToHighest > 3 * tempFold * actualHand->getSmallBlind() && potential<2) || (setToHighest > 9 * tempFold * actualHand->getSmallBlind() && potential<3) || (setToHighest > 20*tempFold * actualHand->getSmallBlind() && potential<4) || (setToHighest > 40 *tempFold * actualHand->getSmallBlind() && potential<5)) && percent < 0.90 && bluff > 18) {
myAction=1;
2007-01-13 02:40:33 +00:00
}
2007-03-17 21:33:46 +00:00
else {
// CHECK und BET --> wenn noch keiner was gesetzt hat
if(actualHand->getFlop()->getHighestSet() == 0) {
// CHECK --> wenn Potential klein oder check-bluff sonst bet oder bet-bluff
if((potential<3 || bluff >= 80) && bluff > 15) {
// check
myAction = 2;
}
// BET --> wenn Potential hoch
2007-01-13 02:40:33 +00:00
else {
2007-03-17 21:33:46 +00:00
if(bluff <= 5) mySet = (bluff+1) * actualHand->getSmallBlind();
else {
if(bluff <=15 ) mySet = 4 * actualHand->getSmallBlind();
// je höher das Potential, desto höher der Einsatz (zur Basis SmallBlind)
else mySet = (potential-1) * 2 * actualHand->getSmallBlind();
}
// All In
if(mySet >= myCash) {
mySet = myCash;
myCash = 0;
myAction = 6;
}
// sonst
else {
myCash -= mySet;
myAction = 4;
}
2007-01-13 02:40:33 +00:00
actualHand->getFlop()->setHighestSet(mySet);
}
2007-03-17 21:33:46 +00:00
2007-01-13 02:40:33 +00:00
}
2007-03-17 21:33:46 +00:00
// CALL und RAISE --> wenn bereits gesetzt wurde
else {
// RAISE --> wenn Potential besonders gut
if((potential >=4 && 2 * tempFold * actualHand->getSmallBlind() >= actualHand->getFlop()->getHighestSet()) || (bluff <= 5 && 4 * tempFold * actualHand->getSmallBlind() >= actualHand->getFlop()->getHighestSet())) {
// bluff - raise
if(bluff <=5) raise = ((bluff+1)/2) * actualHand->getFlop()->getHighestSet();
// Betrag, der ber dem aktuell HighestSet gesetzt werden soll
else raise = ((potential - 2 ) / 2) * actualHand->getFlop()->getHighestSet();
// All In
if(actualHand->getFlop()->getHighestSet() + raise >= myCash) {
mySet += myCash;
myCash = 0;
myAction = 6;
if(mySet > actualHand->getFlop()->getHighestSet()) actualHand->getFlop()->setHighestSet(mySet);
}
// sonst
else {
myCash = myCash + mySet - actualHand->getFlop()->getHighestSet() - raise;
mySet = actualHand->getFlop()->getHighestSet() + raise;
actualHand->getFlop()->setHighestSet(mySet);
myAction = 5;
}
2007-01-13 02:40:33 +00:00
}
2007-03-17 21:33:46 +00:00
// CALL --> bei normalen Potential
2007-01-13 02:40:33 +00:00
else {
2007-03-17 21:33:46 +00:00
// All In
if(actualHand->getFlop()->getHighestSet() >= myCash) {
mySet += myCash;
myCash = 0;
myAction = 6;
}
// sonst
else {
myCash = myCash - actualHand->getFlop()->getHighestSet() + mySet;
mySet = actualHand->getFlop()->getHighestSet();
myAction = 3;
}
2007-01-13 02:40:33 +00:00
}
}
2007-03-17 21:33:46 +00:00
}
}
// ################### ENGINE 0.4 #################
else {
// cout << "Engine 0.4" << endl;
int tempArray[5];
int boardCards[5];
int i;
2007-01-13 02:40:33 +00:00
2007-03-17 21:33:46 +00:00
for(i=0; i<2; i++) tempArray[i] = myCards[i];
actualBoard->getMyCards(boardCards);
for(i=0; i<3; i++) tempArray[2+i] = boardCards[i];
// for(i=0; i<5; i++) cout << tempArray[i] << " ";
// cout << endl;
2007-03-18 00:14:09 +00:00
cout << myID << ": ";
flopCardsValue(tempArray);
2007-03-17 21:33:46 +00:00
}
2007-01-13 02:40:33 +00:00
}
2007-03-18 00:14:09 +00:00
2007-01-13 02:40:33 +00:00
void LocalPlayer::turnEngine() {
2007-03-18 00:14:09 +00:00
ConfigFile myConfig;
if(myConfig.readConfigInt("EngineVersion")) {
// cout << "Engine 0.3" << endl;
2007-01-13 02:40:33 +00:00
2007-03-18 00:14:09 +00:00
// Prozent ausrechnen
int i, j, k;
int tempBoardCardsArray[5];
int tempMyCardsArray[7];
int tempOpponentCardsArray[7];
actualBoard->getMyCards(tempBoardCardsArray);
tempMyCardsArray[0] = myCards[0];
tempMyCardsArray[1] = myCards[1];
tempMyCardsArray[2] = tempBoardCardsArray[0];
tempMyCardsArray[3] = tempBoardCardsArray[1];
tempMyCardsArray[4] = tempBoardCardsArray[2];
tempMyCardsArray[5] = tempBoardCardsArray[3];
tempOpponentCardsArray[2] = tempBoardCardsArray[0];
tempOpponentCardsArray[3] = tempBoardCardsArray[1];
tempOpponentCardsArray[4] = tempBoardCardsArray[2];
tempOpponentCardsArray[5] = tempBoardCardsArray[3];
int tempMyCardsValue;
int tempOpponentCardsValue;
int countAll = 0;
int countMy = 0;
for(i=0; i<49; i++) {
if(i != myCards[0] && i != myCards[1] && i != tempBoardCardsArray[0] && i != tempBoardCardsArray[1] && i != tempBoardCardsArray[2]) {
for(j=i+1; j<50; j++) {
if(j != myCards[0] && j != myCards[1] && j != tempBoardCardsArray[0] && j != tempBoardCardsArray[1] && j != tempBoardCardsArray[2]) {
for(k=j+1; k<51; k++) {
if(k != myCards[0] && k != myCards[1] && k != tempBoardCardsArray[0] && k != tempBoardCardsArray[1] && k != tempBoardCardsArray[2]) {
countAll++;
tempOpponentCardsArray[0] = i;
tempOpponentCardsArray[1] = j;
tempOpponentCardsArray[6] = k;
tempMyCardsArray[6] = k;
tempMyCardsValue = myCardsValue->cardsValue(tempMyCardsArray,0);
tempOpponentCardsValue = myCardsValue->cardsValue(tempOpponentCardsArray,0);
if(tempMyCardsValue>=tempOpponentCardsValue) countMy++;
}
}
2007-01-13 02:40:33 +00:00
}
}
}
}
2007-03-18 00:14:09 +00:00
double percent = (countMy*1.0)/(countAll*1.0);
// cout << "Prozent: " << percent << endl;
Tools myTool;
int raise;
// Bauchgefhl (zufᅵlig)
int tempRand;
myTool.getRandNumber((int)(percent*10.)-2,(int)(percent*10.)+2,1,&tempRand,0);
// bluff, checkbluff
int bluff;
myTool.getRandNumber(1,100,1,&bluff,0);
// cout << "turn-bluff " << bluff << endl;
// Potential
int potential = (10*(5*(int)(percent*100.)+10*tempRand*2))/700-myDude;
int setToHighest = actualHand->getTurn()->getHighestSet() - mySet;
// temp fr das Vielfache des Small Blind, sodass HighestSet zu hoch ist
int tempFold;
// tempFold = (actualHand->getPlayerArray()[0]->getMyAverageSets())/(7*actualHand->getSmallBlind());
myTool.getRandNumber(3,4,1,&tempFold,0);
// FOLD
// --> wenn potential negativ oder HighestSet zu hoch
if( (potential*setToHighest<0 || (setToHighest > tempFold * actualHand->getSmallBlind() && potential<1) || (setToHighest > 3 * tempFold * actualHand->getSmallBlind() && potential<2) || (setToHighest > 9 * tempFold * actualHand->getSmallBlind() && potential<3) || (setToHighest > 20*tempFold * actualHand->getSmallBlind() && potential<4) || (setToHighest > 40 *tempFold * actualHand->getSmallBlind() && potential<5)) && percent < 0.90 && bluff > 15) {
myAction=1;
2007-01-13 02:40:33 +00:00
}
2007-03-18 00:14:09 +00:00
else {
// CHECK und BET --> wenn noch keiner was gesetzt hat
if(actualHand->getTurn()->getHighestSet() == 0) {
// CHECK --> wenn Potential klein
if((potential<2 || bluff >= 80) && bluff > 10) {
// check
myAction = 2;
}
// BET --> wenn Potential hoch
2007-01-13 02:40:33 +00:00
else {
2007-03-18 00:14:09 +00:00
if(bluff <= 3) mySet = bluff * 2 * actualHand->getSmallBlind();
else {
if(bluff <=10 ) mySet = ((bluff+2)/3) * actualHand->getSmallBlind();
// je hᅵer das Potential, desto hᅵher der Einsatz (zur Basis SmallBlind)
else mySet = (potential-1) * 3 * actualHand->getSmallBlind();
}
// All In
if(mySet >= myCash) {
mySet = myCash;
myCash = 0;
myAction = 6;
}
// sonst
else {
myCash -= mySet;
myAction = 4;
}
2007-01-13 02:40:33 +00:00
actualHand->getTurn()->setHighestSet(mySet);
}
2007-03-18 00:14:09 +00:00
2007-01-13 02:40:33 +00:00
}
2007-03-18 00:14:09 +00:00
// CALL und RAISE --> wenn bereits gesetzt wurde
else {
// RAISE --> wenn Potential besonders gut
if(potential >=4 && 2 * tempFold * actualHand->getSmallBlind() >= actualHand->getTurn()->getHighestSet() || (bluff <= 4 && 3 * tempFold * actualHand->getSmallBlind() >= actualHand->getTurn()->getHighestSet())) {
// bluff - raise
if(bluff <= 4) raise = ((bluff+1)/2) * actualHand->getTurn()->getHighestSet();
// Betrag, der ber dem aktuell HighestSet gesetzt werden soll
else raise = ( potential - 3 ) * actualHand->getTurn()->getHighestSet();
// All In
if(actualHand->getTurn()->getHighestSet() + raise >= myCash) {
mySet += myCash;
myCash = 0;
myAction = 6;
if(mySet > actualHand->getTurn()->getHighestSet()) actualHand->getTurn()->setHighestSet(mySet);
}
// sonst
else {
myCash = myCash + mySet - actualHand->getTurn()->getHighestSet() - raise;
mySet = actualHand->getTurn()->getHighestSet() + raise;
actualHand->getTurn()->setHighestSet(mySet);
myAction = 5;
}
2007-01-13 02:40:33 +00:00
}
2007-03-18 00:14:09 +00:00
// CALL --> bei normalen Potential
2007-01-13 02:40:33 +00:00
else {
2007-03-18 00:14:09 +00:00
// All In
if(actualHand->getTurn()->getHighestSet() >= myCash) {
mySet += myCash;
myCash = 0;
myAction = 6;
}
// sonst
else {
myCash = myCash - actualHand->getTurn()->getHighestSet() + mySet;
mySet = actualHand->getTurn()->getHighestSet();
myAction = 3;
}
2007-01-13 02:40:33 +00:00
}
}
2007-03-18 00:14:09 +00:00
}
}
// ################### ENGINE 0.4 #################
else {
// cout << "Engine 0.4" << endl;
int tempArray[6];
int boardCards[5];
int i;
for(i=0; i<2; i++) tempArray[i] = myCards[i];
actualBoard->getMyCards(boardCards);
for(i=0; i<4; i++) tempArray[2+i] = boardCards[i];
// for(i=0; i<5; i++) cout << tempArray[i] << " ";
// cout << endl;
cout << myID << ": ";
turnCardsValue(tempArray);
}
2007-01-13 02:40:33 +00:00
}
2007-03-18 00:14:09 +00:00
2007-01-13 02:40:33 +00:00
void LocalPlayer::riverEngine() {
// Prozent ausrechnen
int i, j;
int tempBoardCardsArray[5];
int tempMyCardsArray[7];
int tempOpponentCardsArray[7];
actualBoard->getMyCards(tempBoardCardsArray);
tempMyCardsArray[0] = myCards[0];
tempMyCardsArray[1] = myCards[1];
tempMyCardsArray[2] = tempBoardCardsArray[0];
tempMyCardsArray[3] = tempBoardCardsArray[1];
tempMyCardsArray[4] = tempBoardCardsArray[2];
tempMyCardsArray[5] = tempBoardCardsArray[3];
tempMyCardsArray[6] = tempBoardCardsArray[4];
tempOpponentCardsArray[2] = tempBoardCardsArray[0];
tempOpponentCardsArray[3] = tempBoardCardsArray[1];
tempOpponentCardsArray[4] = tempBoardCardsArray[2];
tempOpponentCardsArray[5] = tempBoardCardsArray[3];
tempOpponentCardsArray[6] = tempBoardCardsArray[4];
int tempMyCardsValue;
int tempOpponentCardsValue;
int countAll = 0;
int countMy = 0;
for(i=0; i<49; i++) {
if(i != myCards[0] && i != myCards[1] && i != tempBoardCardsArray[0] && i != tempBoardCardsArray[1] && i != tempBoardCardsArray[2]) {
for(j=i+1; j<50; j++) {
if(j != myCards[0] && j != myCards[1] && j != tempBoardCardsArray[0] && j != tempBoardCardsArray[1] && j != tempBoardCardsArray[2]) {
countAll++;
tempOpponentCardsArray[0] = i;
tempOpponentCardsArray[1] = j;
2007-01-28 00:17:49 +00:00
tempMyCardsValue = myCardsValue->cardsValue(tempMyCardsArray,0);
tempOpponentCardsValue = myCardsValue->cardsValue(tempOpponentCardsArray,0);
2007-01-13 02:40:33 +00:00
if(tempMyCardsValue>=tempOpponentCardsValue) countMy++;
}
}
}
}
double percent = (countMy*1.0)/(countAll*1.0);
// cout << "Prozent: " << percent << endl;
Tools myTool;
int raise;
// Bauchgefhl (zufᅵlig)
int tempRand;
myTool.getRandNumber((int)(percent*10.)-2,(int)(percent*10.)+2,1,&tempRand,0);
// bluff, checkbluff
int bluff;
myTool.getRandNumber(1,100,1,&bluff,0);
// cout << "river-bluff " << bluff << endl;
// Potential
int potential = (10*(5*(int)(percent*100.)+10*tempRand*1))/600-myDude;
int setToHighest = actualHand->getRiver()->getHighestSet() - mySet;
// temp fr das Vielfache des Small Blind, sodass HighestSet zu hoch ist
int tempFold;
tempFold = (actualHand->getPlayerArray()[0]->getMyAverageSets())/(6*actualHand->getSmallBlind());
// myTool.getRandNumber(4,6,1,&tempFold,0);
// FOLD
// --> wenn potential negativ oder HighestSet zu hoch
if( (potential*setToHighest<0 || (setToHighest > tempFold * actualHand->getSmallBlind() && potential<1) || (setToHighest > 3 * tempFold * actualHand->getSmallBlind() && potential<2) || (setToHighest > 9 * tempFold * actualHand->getSmallBlind() && potential<3) || (setToHighest > 20*tempFold * actualHand->getSmallBlind() && potential<4) || (setToHighest > 40 *tempFold * actualHand->getSmallBlind() && potential<5)) && percent < 0.90 && bluff > 15) {
myAction=1;
}
else {
// CHECK und BET --> wenn noch keiner was gesetzt hat
if(actualHand->getRiver()->getHighestSet() == 0) {
// CHECK --> wenn Potential klein
if((potential<2 || bluff >= 92) && bluff > 15) {
// check
myAction = 2;
}
// BET --> wenn Potential hoch
else {
if(bluff <= 5) mySet = (bluff+3) * actualHand->getSmallBlind();
else {
if(bluff <= 15 ) mySet = ((bluff-1)/5) * 2 * actualHand->getSmallBlind();
// je hᅵer das Potential, desto hᅵher der Einsatz (zur Basis SmallBlind)
else mySet = (potential-1) * 4 * actualHand->getSmallBlind();
}
// All In
if(mySet >= myCash) {
mySet = myCash;
myCash = 0;
myAction = 6;
}
// sonst
else {
myCash -= mySet;
myAction = 4;
}
actualHand->getRiver()->setHighestSet(mySet);
}
}
// CALL und RAISE --> wenn bereits gesetzt wurde
else {
// RAISE --> wenn Potential besonders gut
if(potential >=4 && 2 * tempFold * actualHand->getSmallBlind() >= actualHand->getRiver()->getHighestSet() || (bluff <= 2 && 4 * tempFold * actualHand->getSmallBlind() >= actualHand->getRiver()->getHighestSet())) {
// bluff - raise
if(bluff <= 2 ) raise = bluff * actualHand->getRiver()->getHighestSet();
// Betrag, der ber dem aktuell HighestSet gesetzt werden soll
else raise = ( potential - 3 ) * actualHand->getRiver()->getHighestSet();
// All In
if(actualHand->getRiver()->getHighestSet() + raise >= myCash) {
mySet += myCash;
myCash = 0;
myAction = 6;
if(mySet > actualHand->getRiver()->getHighestSet()) actualHand->getRiver()->setHighestSet(mySet);
}
// sonst
else {
myCash = myCash + mySet - actualHand->getRiver()->getHighestSet() - raise;
mySet = actualHand->getRiver()->getHighestSet() + raise;
actualHand->getRiver()->setHighestSet(mySet);
myAction = 5;
}
}
// CALL --> bei normalen Potential
else {
// All In
if(actualHand->getRiver()->getHighestSet() >= myCash) {
mySet += myCash;
myCash = 0;
myAction = 6;
}
// sonst
else {
myCash = myCash - actualHand->getRiver()->getHighestSet() + mySet;
mySet = actualHand->getRiver()->getHighestSet();
myAction = 3;
}
}
}
}
}
2007-03-17 21:33:46 +00:00
2007-03-18 00:14:09 +00:00
int LocalPlayer::flopCardsValue(int* cards) {
2007-03-17 21:33:46 +00:00
int array[5][3];
int j1, j2, j3, j4, k1, k2, ktemp[3];
// Kartenwerte umwandeln (z.B. [ 11 (Karo Kig) -> 0 11 ] oder [ 31 (Pik 7) -> 2 5 ] )
for(j1=0; j1<5; j1++) {
array[j1][0] = cards[j1]/13;
array[j1][1] = cards[j1]%13;
array[j1][2] = j1;
}
// Karten nach Farben sortieren: Kreuz - Pik - Herz - Karo
for(k1=0; k1<5; k1++) {
for(k2=k1+1; k2<5; k2++) {
if(array[k1][0]<array[k2][0]) {
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];
}
}
}
// Karten innerhalb der Farben nach der Gre sortieren: Ass - Kig - Dame - ... - 4 - 3 - 2
for(k1=0; k1<5; k1++) {
for(k2=k1+1; k2<5; k2++) {
if(array[k1][0]==array[k2][0] && array[k1][1]<array[k2][1]) {
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 Straight Flush und Flush testen
// 5 Karten gleiche Farbe ?
if(array[0][0] == array[1][0] && array[0][0] == array[2][0] && array[0][0] == array[3][0] && array[0][0] == array[4][0]) {
// Straight Flush?
if(array[0][1]-4 == array[4][1]) {
cout << "Straight Flush" << endl;
// -> Sieg -> alles mitgehen
return 100;
}
else {
// Straight Flush Ausnahme: 5-4-3-2-A
if(array[0][1]==12 && array[1][1]==3 && array[2][1]==2 && array[3][1]==1 && array[4][1]==0) {
cout << "Straight Flush Ass unten" << endl;
// -> fast sicherer Sieg -> alles mitgehen
return 99;
}
// Flush
else {
cout << "Flush" << endl;
// -> sehr gutes Blatt -> eigenen Anteil ermitteln und auf andere achten
return 70;
}
}
}
// auf Straight Flush Draw und Flush Draw testen
for(j1=0; j1<2; j1++) {
// 4 Karten gleiche Farbe ?
if(array[j1][0] == array[j1+1][0] && array[j1][0] == array[j1+2][0] && array[j1][0] == array[j1+3][0]) {
// zusammenhaengender Strassenansatz ?
if(array[j1][1]-3 == array[j1+3][1]) {
// Strassenansatz am Rand?
if(array[j1][1] == 12) {
cout << "zusammenhaengender Straight-Flush-Draw mit Ass high ";
break;
}
// Strassenansatz in der Mitte
else {
cout << "zusammenhaengender Straight-Flush-Draw in der Mitte ";
break;
}
}
else {
// Bauchschuss ?
if(array[j1][1]-4 == array[j1+3][1]) {
cout << "Straight-Flush-Bauchschuss ";
break;
}
else {
// Test auf Straight-Flush-Ausnahme 5-4-3-2-A
if(array[j1][1] == 12 && (array[j1+1][1]<=3 || (array[j1+2][1]<=3 && array[j1][0]==array[j1+4][0]))) {
cout << "Straight-Flush-Draw Ass unten ";
break;
}
// Flush Draw
else {
cout << "Flush Draw ";
break;
}
}
}
}
}
// Karten fr den Vierling-, Full-House-, Drilling- und Paartest umsortieren
for(k1=0; k1<5; k1++) {
for(k2=k1+1; k2<5; k2++) {
if(array[k1][1]<array[k2][1]) {
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 testen
for(j1=0; j1<2; j1++) {
if(array[j1][1] == array[j1+1][1] && array[j1][1] == array[j1+2][1] && array[j1][1] == array[j1+3][1]) {
cout << "Vierling" << endl;
// -> Sieg (nur von Sraight Flush schlagbar) -> alles mitgehn
return 100;
}
}
2007-03-18 00:14:09 +00:00
// auf Straight und Full House testen
// Straight
if((array[0][1]-1 == array[1][1] || array[0][1]-9 == array[1][1] ) && array[1][1]-1 == array[2][1] && array[2][1]-1 == array[3][1] && array[3][1]-1 == array[4][1]) {
cout << "Straight" << endl;
// -> super Blatt -> auf andere achten
return 70;
}
// Full House
if((array[0][1] == array[1][1] && array[0][1] == array[2][1] && array[3][1] == array[4][1]) || (array[2][1] == array[3][1] && array[2][1] == array[4][1] && array[0][1] == array[1][1])) {
cout << "Full House" << endl;
// -> super Blatt -> auf andere achten
return 70;
}
2007-03-17 21:33:46 +00:00
// auf Straßenansatz testen
for(j1=0; j1<5; j1++) {
for(j2=j1+1; j2<5; j2++) {
for(j3=j2+1; j3<5; j3++) {
for(j4=j3+1; j4<5; j4++) {
// zusammenhaengender Strassenansatz ?
if((array[j1][1]-1 == array[j2][1] || array[j1][1]-9 == array[j2][1]) && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1]) {
// Strassenansatz am Rand?
if(array[j1][1] == 12) {
cout << "zusammenhaengender Straight-Draw mit Ass high ";
break;
}
// Strassenansatz in der Mitte
else {
cout << "zusammenhaengender Straight-Draw in der Mitte ";
break;
}
}
else {
// Bauchschuss ?
if((array[j1][1]-2 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1]) || (array[j1][1]-1 == array[j2][1] && array[j2][1]-2 == array[j3][1] && array[j3][1]-1 == array[j4][1]) || (array[j1][1]-1 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-2 == array[j4][1])) {
cout << "Straight-Bauchschuss ";
break;
}
else {
// Test auf Straßenansatz-Ausnahme 5-4-3-2-A
if((array[j1][1]-9 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1]) || (array[j1][1]-9 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-2 == array[j4][1]) || (array[j1][1]-9 == array[j2][1] && array[j2][1]-2 == array[j3][1] && array[j3][1]-1 == array[j4][1]) || (array[j1][1]-10 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1])) {
cout << "Straight-Draw Ass unten ";
break;
}
}
}
}
}
}
}
// auf Drilling testen
for(j1=0; j1<3; j1++) {
if(array[j1][1] == array[j1+1][1] && array[j1][1] == array[j1+2][1]) {
cout << "Drilling" << endl;
// -> gutes Blatt -> eigenen Anteil ermitteln und auf andere achten
return 50;
}
}
// auf Zwei Paare testen
for(j1=0; j1<2; j1++) {
for(j2=j1+2; j2<4; j2++) {
if(array[j1][1] == array[j1+1][1] && array[j2][1] == array[j2+1][1]) {
cout << "Zwei Paare" << endl;
// -> gutes Blatt -> eigenen Anteil ermitteln und auf andere achten
return 40;
}
}
}
// auf Paar testen
for(j1=0; j1<4; j1++) {
if(array[j1][1] == array[j1+1][1]) {
cout << "Paar" << endl;
// -> gutes Blatt -> eigenen Anteil ermitteln und auf andere achten
return 30;
}
}
// Highest Card (Klasse 0) + Kicker
cout << endl;
return 10;
}
2007-03-18 00:14:09 +00:00
int LocalPlayer::turnCardsValue(int* cards) {
int array[6][3];
int j1, j2, j3, j4, j5, k1, k2, ktemp[3];
// Kartenwerte umwandeln (z.B. [ 11 (Karo Kig) -> 0 11 ] oder [ 31 (Pik 7) -> 2 5 ] )
for(j1=0; j1<6; j1++) {
array[j1][0] = cards[j1]/13;
array[j1][1] = cards[j1]%13;
array[j1][2] = j1;
}
// Karten nach Farben sortieren: Kreuz - Pik - Herz - Karo
for(k1=0; k1<6; k1++) {
for(k2=k1+1; k2<6; k2++) {
if(array[k1][0]<array[k2][0]) {
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];
}
}
}
// Karten innerhalb der Farben nach der Gre sortieren: Ass - Kig - Dame - ... - 4 - 3 - 2
for(k1=0; k1<6; k1++) {
for(k2=k1+1; k2<6; k2++) {
if(array[k1][0]==array[k2][0] && array[k1][1]<array[k2][1]) {
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 Straight Flush und Flush testen
// 5 Karten gleiche Farbe ?
for(j1=0; j1<2; j1++) {
// 5 Karten gleiche Farbe ?
if(array[j1][0] == array[j1+1][0] && array[j1][0] == array[j1+2][0] && array[j1][0] == array[j1+3][0] && array[j1][0] == array[j1+4][0]) {
// Straight Flush?
if(array[j1][1]-4 == array[j1+4][1]) {
cout << "Straight Flush" << endl;
// -> Sieg -> alles mitgehen
return 100;
}
else {
// Straight Flush Ausnahme: 5-4-3-2-A
for(j2=j1+1; j2<3; j2++) {
if(array[j1][1]-9==array[j2][1] && array[j2][1]-1==array[j2+1][1] && array[j2+1][1]-1==array[j2+2][1] && array[j2+2][1]-1==array[j2+3][1] && array[j1][0]==array[j2+2][0] && array[j1][0]==array[j2+3][0]) {
cout << "Straight Flush Ass unten" << endl;
// -> fast sicherer Sieg -> alles mitgehen
return 99;
}
}
}
}
}
// auf Flush testen
for(j1=0; j1<2; j1++) {
if(array[j1][0] == array[j1+1][0] && array[j1][0] == array[j1+2][0] && array[j1][0] == array[j1+3][0] && array[j1][0] == array[j1+4][0]) {
cout << "Flush" << endl;
// -> sehr gutes Blatt -> eigenen Anteil ermitteln und auf andere achten
return 70;
}
}
// auf Straight Flush Draw und Flush Draw testen
for(j1=0; j1<3; j1++) {
// 4 Karten gleiche Farbe ?
if(array[j1][0] == array[j1+1][0] && array[j1][0] == array[j1+2][0] && array[j1][0] == array[j1+3][0]) {
// zusammenhaengender Strassenansatz ?
if(array[j1][1]-3 == array[j1+3][1]) {
// Strassenansatz am Rand?
if(array[j1][1] == 12) {
cout << "zusammenhaengender Straight-Flush-Draw mit Ass high ";
break;
}
// Strassenansatz in der Mitte
else {
cout << "zusammenhaengender Straight-Flush-Draw in der Mitte ";
break;
}
}
else {
// Bauchschuss ?
if(array[j1][1]-4 == array[j1+3][1]) {
cout << "Straight-Flush-Bauchschuss ";
break;
}
else {
// Test auf Straight-Flush-Ausnahme 5-4-3-2-A
if(array[j1][1] == 12 && (array[j1+1][1]<=3 || (array[j1+2][1]<=3 && array[j1][0]==array[j1+4][0]) || (array[j1+3][1]<=3 && array[j1][0]==array[j1+4][0] && array[j1][0]==array[j1+4][0]))) {
cout << "Straight-Flush-Draw Ass unten ";
break;
}
// Flush Draw
else {
cout << "Flush Draw ";
break;
}
}
}
}
}
// Karten fr den Vierling-, Full-House-, Drilling- und Paartest umsortieren
for(k1=0; k1<6; k1++) {
for(k2=k1+1; k2<6; k2++) {
if(array[k1][1]<array[k2][1]) {
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 testen
for(j1=0; j1<3; j1++) {
if(array[j1][1] == array[j1+1][1] && array[j1][1] == array[j1+2][1] && array[j1][1] == array[j1+3][1]) {
cout << "Vierling" << endl;
// -> Sieg (nur von Sraight Flush schlagbar) -> alles mitgehn
return 100;
}
}
// auf Straight und Full House testen
for(j1=0; j1<6; j1++) {
for(j2=j1+1; j2<6; j2++) {
for(j3=j2+1; j3<6; j3++) {
for(j4=j3+1; j4<6; j4++) {
for(j5=j4+1; j5<6; j5++) {
// Straight
if((array[j1][1]-1 == array[j2][1] || array[j1][1]-9 == array[j2][1] ) && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1] && array[j4][1]-1 == array[j5][1]) {
cout << "Straight" << endl;
// -> super Blatt -> auf andere achten
return 70;
}
// Full House
if((array[j1][1] == array[j2][1] && array[j1][1] == array[j3][1] && array[j4][1] == array[j5][1]) || (array[j3][1] == array[j4][1] && array[j3][1] == array[j5][1] && array[j1][1] == array[j2][1])) {
cout << "Full House" << endl;
// -> super Blatt -> auf andere achten
return 70;
}
}
}
}
}
}
// auf Straßenansatz testen
for(j1=0; j1<6; j1++) {
for(j2=j1+1; j2<6; j2++) {
for(j3=j2+1; j3<6; j3++) {
for(j4=j3+1; j4<6; j4++) {
// zusammenhaengender Strassenansatz ?
if(array[j1][1]-1 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1]) {
// Strassenansatz am Rand?
if(array[j1][1] == 12) {
cout << "zusammenhaengender Straight-Draw mit Ass high ";
break;
}
// Strassenansatz in der Mitte
else {
cout << "zusammenhaengender Straight-Draw in der Mitte ";
break;
}
}
else {
// Bauchschuss ?
if((array[j1][1]-2 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1]) || (array[j1][1]-1 == array[j2][1] && array[j2][1]-2 == array[j3][1] && array[j3][1]-1 == array[j4][1]) || (array[j1][1]-1 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-2 == array[j4][1])) {
cout << "Straight-Bauchschuss ";
break;
}
else {
// Test auf Straßenansatz-Ausnahme 5-4-3-2-A
if((array[j1][1]-9 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1]) || (array[j1][1]-9 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-2 == array[j4][1]) || (array[j1][1]-9 == array[j2][1] && array[j2][1]-2 == array[j3][1] && array[j3][1]-1 == array[j4][1]) || (array[j1][1]-10 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1])) {
cout << "Straight-Draw Ass unten ";
break;
}
}
}
}
}
}
}
// auf Drilling testen
for(j1=0; j1<4; j1++) {
if(array[j1][1] == array[j1+1][1] && array[j1][1] == array[j1+2][1]) {
cout << "Drilling" << endl;
// -> gutes Blatt -> eigenen Anteil ermitteln und auf andere achten
return 50;
}
}
// auf Zwei Paare testen
for(j1=0; j1<3; j1++) {
for(j2=j1+2; j2<5; j2++) {
if(array[j1][1] == array[j1+1][1] && array[j2][1] == array[j2+1][1]) {
cout << "Zwei Paare" << endl;
// -> gutes Blatt -> eigenen Anteil ermitteln und auf andere achten
return 40;
}
}
}
// auf Paar testen
for(j1=0; j1<5; j1++) {
if(array[j1][1] == array[j1+1][1]) {
cout << "Paar" << endl;
// -> gutes Blatt -> eigenen Anteil ermitteln und auf andere achten
return 30;
}
}
// Highest Card (Klasse 0) + Kicker
cout << endl;
return 10;
}