engine 0.4 rev3 (flop part 1)

This commit is contained in:
doitux
2007-03-17 21:33:46 +00:00
parent 5b90442470
commit 4ce1814131
2 changed files with 414 additions and 152 deletions
+412 -152
View File
@@ -487,174 +487,196 @@ void LocalPlayer::preflopEngine() {
void LocalPlayer::flopEngine() {
// 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++;
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++;
}
}
}
}
}
}
}
}
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;
}
}
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;
}
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
else {
if(bluff <= 5) mySet = (bluff+1) * actualHand->getSmallBlind();
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
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;
}
actualHand->getFlop()->setHighestSet(mySet);
}
}
// 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;
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;
}
actualHand->getFlop()->setHighestSet(mySet);
myAction = 5;
}
}
// CALL --> bei normalen Potential
else {
// All In
if(actualHand->getFlop()->getHighestSet() >= myCash) {
mySet += myCash;
myCash = 0;
myAction = 6;
// 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;
}
}
// sonst
// CALL --> bei normalen Potential
else {
myCash = myCash - actualHand->getFlop()->getHighestSet() + mySet;
mySet = actualHand->getFlop()->getHighestSet();
myAction = 3;
// 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;
}
}
}
}
}
}
}
// ################### ENGINE 0.4 #################
else {
// cout << "Engine 0.4" << endl;
int tempArray[5];
int boardCards[5];
int i;
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;
preflopCardsValue(tempArray);
}
}
void LocalPlayer::turnEngine() {
@@ -987,3 +1009,241 @@ void LocalPlayer::riverEngine() {
}
}
int LocalPlayer::preflopCardsValue(int* cards) {
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;
}
}
// 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 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;
}
// 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;
}
+2
View File
@@ -94,6 +94,8 @@ public:
void turnEngine();
void riverEngine();
int preflopCardsValue(int*);
private:
HandInterface *actualHand;