ActionRet HoldemTournamentAIManual::valuePlay(const TableTexture& t, bool debug)
{
ActionRet ret;
ret.name="valuePlay";
ret.action=FOLD;
ret.amt=0;
PokerHand h=table->getHand();
PokerHand tmpHand;
bool medHand=false,
goodHand=false,
nutzHand=false;
bool valuebet=false,
slowplay=false;
profile_line(" -- valuePlay() -- ");
bool flushAce=false;
if (t.suited4||t.suited5) {
tmpHand=table->getBoard();
char suit=tmpHand.Flush()[0].GetSuit();
if (h[0].GetSuit()==suit&&h[0].GetIndex()=='A') flushAce=true;
if (h[1].GetSuit()==suit&&h[1].GetIndex()=='A') flushAce=true;
}
tmpHand=table->getBoard()+table->getHand();
bool flush=tmpHand.isFlush()&&(flushAce||!(t.suited4||t.suited5));
if (!t.trips&&!t.pair) {
profile_line("Simple Board");
tmpHand=table->getBoard();
Card boardHigh=tmpHand.HighCard();
if (h[0].GetRank()==boardHigh.GetRank()||h[1].GetRank()==boardHigh.GetRank()) toggleVar(medHand); if (h[0].GetRank()==h[1].GetRank()&&h[0].GetRank()>boardHigh.GetRank()) toggleVar(medHand); tmpHand=table->getBoard()+table->getHand();
Card trip=tmpHand.Trip();
Card p1=tmpHand.Pair();
Card p2=tmpHand.Pair();
if (trip!=NOCARD||(p1!=NOCARD&&p2!=NOCARD)) {
toggleVar(goodHand);
}
tmpHand=table->getBoard()+table->getHand();
if (tmpHand.Quad()!=NOCARD||flush||(tmpHand.Trip()!=NOCARD&&tmpHand.Pair()!=NOCARD)) {
toggleVar(nutzHand);
}
if (table->getStage()==STAGE_FLOP) {
if (tmpHand.Straight()!=NOCARD&& t.suited2) { toggleVar(goodHand); }
if (tmpHand.Straight()!=NOCARD&&!t.suited2) { toggleVar(nutzHand); }
}
if (table->getStage()==STAGE_TURN||table->getStage()==STAGE_RIVER) {
if (tmpHand.Straight()!=NOCARD&& t.suited3) { toggleVar(goodHand); }
if (tmpHand.Straight()!=NOCARD&&!t.suited3) { toggleVar(nutzHand); }
}
}
else if (!t.trips) {
profile_line("Pair Board");
tmpHand=table->getBoard();
Card pair=tmpHand.Pair();
Card pair2=tmpHand.Pair();
Card loneCard=tmpHand.HighCard();
if (loneCard.GetRank()==h[0].GetRank()||loneCard.GetRank()==h[1].GetRank()) toggleVar(medHand); if (h[0].GetRank()==h[1].GetRank()&&h[0].GetRank()>loneCard.GetRank()) toggleVar(medHand); if (h[0].GetRank()==pair.GetRank() ||h[1].GetRank()==pair.GetRank()||
h[0].GetRank()==pair2.GetRank()||h[1].GetRank()==pair2.GetRank()) toggleVar(goodHand); tmpHand=table->getBoard()+table->getHand();
if (tmpHand.Quad()!=NOCARD||flush||(tmpHand.Trip()!=NOCARD&&tmpHand.Pair()!=NOCARD)) {
toggleVar(nutzHand);
}
if (table->getStage()==STAGE_FLOP) {
if (tmpHand.Straight()!=NOCARD&& t.suited2) { toggleVar(goodHand); }
if (tmpHand.Straight()!=NOCARD&&!t.suited2) { toggleVar(nutzHand); }
}
if (table->getStage()==STAGE_TURN||table->getStage()==STAGE_RIVER) {
if (tmpHand.Straight()!=NOCARD&& t.suited3) { toggleVar(goodHand); }
if (tmpHand.Straight()!=NOCARD&&!t.suited3) { toggleVar(nutzHand); }
}
}
else {
profile_line("Weird Board");
tmpHand=table->getBoard()+table->getHand();
if (flush||(tmpHand.Trip()!=NOCARD&&tmpHand.Pair()!=NOCARD)) toggleVar(goodHand);
if (tmpHand.Quad()!=NOCARD) toggleVar(nutzHand);
}
switch (table->getStage())
{
case STAGE_FLOP:
if ((goodHand&&(t.inrow3)&&(t.inrow2)&&!t.suited2)||(nutzHand)) { slowplay=true; }
if (medHand||goodHand||nutzHand) { valuebet=true; }
break;
case STAGE_TURN:
case STAGE_RIVER:
if (!t.dangercard&&(medHand||goodHand||nutzHand)) { valuebet=true; }
if ( t.dangercard&&( goodHand||nutzHand)) { valuebet=true; }
}
if (debug) {
cout << "valuebet: " << valuebet << endl;
cout << " med hand: " << medHand << endl;
cout << " good hand: " << goodHand << endl;
cout << " nutz hand: " << nutzHand << endl;
cout << endl;
}
if (valuebet) {
ret.action=BET;
ret.amt=betPassive();
}
if (slowplay) {
ret.action=CALL;
ret.amt=table->getCostToCall(getAIPlayer());
}
return ret;
}