package com.poker.analyst.strategy;
import java.io.IOException;
import java.util.List;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
import com.poker.analyst.AnalystResult;
import com.poker.analyst.combination.AvailableCombinations;
import com.poker.analyst.combination.AvailableCombinationsTools;
import com.poker.analyst.combination.Combination;
import com.poker.analyst.combination.Flush;
import com.poker.analyst.combination.HighCard;
import com.poker.analyst.combination.Pair;
import com.poker.analyst.combination.Straight;
import com.poker.analyst.combination.TwoPairs;
import com.poker.analyst.combinations.auxil.CardValue;
import com.poker.analyst.element.Board;
import com.poker.analyst.element.Card;
import com.poker.analyst.element.CardFace;
import com.poker.analyst.element.Hand;
import com.poker.analyst.element.Player;
import com.poker.analyst.element.Position;
import com.poker.analyst.element.Suit;
import com.poker.analyst.elements.state.HeroActionOnTurn;
import com.poker.analyst.strategy.temp.ActionBeforePlay;
import com.poker.ui.robot.reaction.UIReaction;
import com.poker.utils.FloatEx;
import com.poker.utils.StringEx;
public class StrategySSS extends Strategy {
Logger logger;
FileHandler fh;
public StrategySSS(String heroName) {
super(heroName);
try {
logger = Logger.getLogger("General");
fh = new FileHandler("c:\\temp\\poker\\sss.log", true);
logger.addHandler(fh);
logger.setLevel(Level.ALL);
SimpleFormatter formatter = new SimpleFormatter();
fh.setFormatter(formatter);
} catch (IOException e) {
}
}
float koeff = 1;
@Override
public boolean maySitToTable(DataForStrategy dfs) {
boolean result = true;
Board board = dfs.getCurrentBoard();
int countSssPlayers = 0;
if (board == null || board.getPlayers() == null)
{
System.err.println(board);
if (board != null)
System.err.println(board.getPlayers());
System.err.println("Xren' kakaja to");
return false;
}
/* System.out.println("==============before sitting=============");
System.out.println("Hero: " + board.getPlayers().get(board.getHero()).getStack());
*/
for (Player player: board.getPlayers()){
// System.out.println(player.getStack());
if (FloatEx.gt4( board.getPlayers().get(board.getHero()).getStack(),player.getStack())){
if (!FloatEx.equals4(player.getStack(), -2))
countSssPlayers++;
}
}
if (countSssPlayers > 3){
logger.log(Level.WARNING,"SSS players > 4");
result = false;
}
if (board.getPlayers().get(board.getHero()).getStack() < 0){
logger.log(Level.WARNING,"hero stack<0");
result = false;
}
return result;
}
@Override
public AnalystResult isNeedRebuy(DataForStrategy dfs) {
return new AnalystResult(null, null);
}
@Override
public ActionBeforePlay getPreparedAction(DataForStrategy dfs) {
Board board = dfs.getCurrentBoard();
// CLOSEWINDOW
if (FloatEx.gt4(board.getPlayers().get(board.getHero()).getStack(),1.25f * board.getBigBlind() * 30)){
logger.log(Level.WARNING,"hero have mush money");
return ActionBeforePlay.ABP_CLOSEWINDOW;
}
int countSssPlayers = 0;
for (Player player: board.getPlayers()){
// if (FloatEx.gt4(30 * board.getBigBlind(),player.getStack())){
if (FloatEx.gt4(1 * board.getBigBlind(),player.getStack())){
if (!FloatEx.equals4(player.getStack(), -2))
countSssPlayers++;
}
}
if (countSssPlayers > 4){
logger.log(Level.WARNING,"SSS players > 5");
return ActionBeforePlay.ABP_CLOSEWINDOW;
}
return null;
}
@Override
public void initHandSets() {
//Если ещё не было повышений, вы повышаете с ...
// 11 set
//Вы в ранней позиции JJ - AA AK
List<Hand> setlist;
setlist = Hand.geterateHandFTS(CardFace.JACK, CardFace.ACE, 0, true, true, true);
setlist.addAll(Hand.geterateHandFTS(CardFace.KING, CardFace.ACE, 0, true, true, false));
//added by me
handSets.put(11, setlist);
//Вы в средней позиции 99 - AA AK, AQ
setlist = Hand.geterateHandFTS(CardFace.NINE, CardFace.ACE, 0, true, true, true);
setlist.addAll(Hand.geterateHandFTSOveral(CardFace.JACK, CardFace.ACE, 0, true, true, false, false, true));
//added by me
/*setlist.addAll(Hand.geterateHandFTSOveral(CardFace.JACK, CardFace.ACE, 0, true, true, false, false, true));
setlist.addAll(Hand.geterateHandFTSOveral(CardFace.KING, CardFace.ACE, 0, false, true, false, false, true));
*/ setlist.addAll(Hand.geterateHandFTSOveral(CardFace.QUEEN, CardFace.KING, 0, true, false, false, false, true));
handSets.put(12, setlist);
//Вы в поздней позиции или на блайндах 77 - AA AT, AJ, AQ, AK, KQ
setlist = Hand.geterateHandFTS(CardFace.SEVEN, CardFace.ACE, 0, true, true, true);
setlist.addAll(Hand.geterateHandFTSOveral(CardFace.TEN, CardFace.ACE, 0, true, true, false, false, true));
setlist.addAll(Hand.geterateHandFTSOveral(CardFace.QUEEN, CardFace.KING, 0, true, false, false, false, false));
setlist.addAll(Hand.geterateHandFTSOveral(CardFace.JACK, CardFace.KING, 0, true, false, false, false, false));
// setlist.addAll(Hand.geterateHandFTSOveral(CardFace.TEN, CardFace.JACK, 0, true, false, false, false, false));
//added by me
// setlist.addAll(Hand.geterateHandFTSOveral(CardFace.TEN, CardFace.JACK, 0, true, false, false, false, false));
handSets.put(13, setlist);
//Вы в поздней позиции или на блайндах 77 - AA AT, AJ, AQ, AK, KQ
// adds QJ, KTs
// if no limpers && no raises
setlist = Hand.geterateHandFTS(CardFace.SEVEN, CardFace.ACE, 0, true, true, true);
setlist.addAll(Hand.geterateHandFTSOveral(CardFace.TEN, CardFace.ACE, 0, true, true, false, false, true));
setlist.addAll(Hand.geterateHandFTSOveral(CardFace.QUEEN, CardFace.KING, 0, true, false, false, false, false));
setlist.addAll(Hand.geterateHandFTSOveral(CardFace.JACK, CardFace.KING, 0, true, false, false, true, true));
setlist.addAll(Hand.geterateHandFTSOveral(CardFace.JACK, CardFace.QUEEN, 0, true, false, false, false, false));
handSets.put(131, setlist);
//Вы на блайндах 77 - AA AT, AJ, AQ, AK, KQ
// adds QJ, KTs
// if no limpers && no raises
setlist = Hand.geterateHandFTS(CardFace.SEVEN, CardFace.ACE, 0, true, true, true);
setlist.addAll(Hand.geterateHandFTSOveral(CardFace.TEN, CardFace.ACE, 0, true, true, false, false, true));
setlist.addAll(Hand.geterateHandFTSOveral(CardFace.QUEEN, CardFace.KING, 0, true, true, false, false, false));
setlist.addAll(Hand.geterateHandFTSOveral(CardFace.JACK, CardFace.KING, 0, true, false, false, true, true));
setlist.addAll(Hand.geterateHandFTSOveral(CardFace.JACK, CardFace.QUEEN, 0, true, true, false, false, false));
handSets.put(141, setlist);
//Если соперники устроили экшен, вы идёте олл-ин с ...
//Перед вами было одно повышение JJ - AA AK
setlist = Hand.geterateHandFTS(CardFace.JACK, CardFace.ACE, 0, true, true, true);
setlist.addAll(Hand.geterateHandFTS(CardFace.KING, CardFace.ACE, 0, true, true, false));
handSets.put(21, setlist);
//Перед вами было 2 и больше повышений KK, AA
setlist = Hand.geterateHandFTS(CardFace.KING, CardFace.ACE, 0, true, true, true);
handSets.put(22, setlist);
//После вас было повышение TT - AA AK
setlist = Hand.geterateHandFTS(CardFace.TEN, CardFace.ACE, 0, true, true, true);
setlist.addAll(Hand.geterateHandFTS(CardFace.KING, CardFace.ACE, 0, true, true, false));
handSets.put(23, setlist);
//Рестилы
//Вы рестилите с 88 - AA AJ - AK
setlist = Hand.geterateHandFTS(CardFace.EIGHT, CardFace.ACE, 0, true, true, true);
setlist.addAll(Hand.geterateHandFTSOveral(CardFace.JACK, CardFace.ACE, 0, true, true, false, false, true));
handSets.put(31, setlist);
//В ответ на рестил оппонента вы идёте олл-ин с 99 - AA,AJ - AK
setlist = Hand.geterateHandFTS(CardFace.NINE, CardFace.ACE, 0, true, true, true);
setlist.addAll(Hand.geterateHandFTSOveral(CardFace.JACK, CardFace.ACE, 0, true, true, false, false, true));
handSets.put(32, setlist);
// hands for call
//Calls
//KQs , QJs
setlist = Hand.geterateHandFTS(CardFace.QUEEN, CardFace.KING, 0, true, false, false);
setlist.addAll(Hand.geterateHandFTS(CardFace.JACK, CardFace.QUEEN, 0, true, false, false));
handSets.put(41, setlist);
//KQs KJs QJs
setlist = Hand.geterateHandFTS(CardFace.JACK, CardFace.KING, 0, true, false, false);
handSets.put(42, setlist);
}
@Override
public AnalystResult getPreFlopReaction(DataForStrategy dfs) {
Board board = dfs.getCurrentBoard();
float bb = board.getBigBlind();
boolean isFirstCircle = true;
int limpersCount = -1;
float limpersBet = bb;
float raiseAmount = 0;
float maxBet;
// float stackOfFirstRaiser = -1f;
int callers = 0;
Hand heroHand = new Hand();
heroHand.setHandCards(board.getPlayingCards().getPlayerCards());
maxBet = 0;
for (Player pl: board.getPlayers()){
if (FloatEx.gt4(pl.getBet(), maxBet))
maxBet = pl.getBet();
}
koeff = 1.25f;
double rand = Math.random();
if (rand <= 0.2)
koeff -= 0.05;
if (rand >= 0.8)
koeff += 0.05;
if (board.isFirstAuction()){
isFirstCircle = true;
if (!board.getPlayers().get(board.getHero()).getName().trim().equals("") &&
!board.getPlayers().get(board.getHero()).getName().trim().equals(heroName)){
logger.log(Level.WARNING,"REASON: heroname != " + board.getPlayers().get(board.getHero()).getName().trim());
return new AnalystResult(UIReaction.UIR_ACTION_FOLD, "ONLYFOLD");
}
}
else {
isFirstCircle = false;
if (!heroName.equals(board.getPlayers().get(board.getHero()).getName().trim())){
logger.log(Level.WARNING,"REASON: heroname != " + board.getPlayers().get(board.getHero()).getName().trim());
return new AnalystResult(UIReaction.UIR_ACTION_FOLD, "ONLYFOLD");
}
}
limpersBet = bb;
if (board.getNumOfRaises() == 1 && maxBet < 2.1f * bb && isFirstCircle){
limpersBet = maxBet;
board.setNumOfRaises(0);
}
for (Player player: board.getPlayers()){
if (FloatEx.equals4(player.getBet() - limpersBet,0f))
limpersCount ++;
}
int tmp;
int firstRaiserPosition = -1;
if (board.getNumOfRaises() != 0){
if (board.getNumOfRaises() == 1){
tmp = 0;
for (int i = 0; i< board.getPlayers().size(); i++){
if (FloatEx.equals4(board.getPlayers().get(i).getBet(), maxBet)){
if (firstRaiserPosition == -1)
firstRaiserPosition = i;
tmp++;
}
}
raiseAmount = FloatEx.cutFloat2(new Float(koeff * maxBet * (3 + tmp)));
callers = tmp;
}else{
raiseAmount = board.getPlayers().get(board.getHero()).getStack();
}
}
else{
raiseAmount = FloatEx.cutFloat2(new Float(koeff * limpersBet *(4 + limpersCount) ) );
}
if (raiseAmount > 1f){
raiseAmount = raiseAmount * 10;
raiseAmount = FloatEx.cutFloat2(0.1f * Math.round(raiseAmount));
}
/*
if (raiseAmount > dfs.getPlayerMoney() * 2.0f / 3.0f)
raiseAmount = dfs.getPlayerMoney();
*/
logger.log(Level.WARNING,"mBet: " + maxBet + "; limpC: " + limpersCount + "; rA" + raiseAmount + "; numRaise: " + board.getNumOfRaises() + "; callers: " + callers);
logger.log(Level.WARNING,"position:" + board.getPosition());
if (isFirstCircle){
switch (board.getPosition()) {
case EARLY_POSITION:
// no raises
if (board.getNumOfRaises() == 0){
if (checkHandForHSet(heroHand,11)){
board.setHeroActionOnTurn(HeroActionOnTurn.HAOT_RAISE);
logger.log(Level.WARNING,"REASON: (RAISE) heroHand,11");
return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
}
}else
if (board.getNumOfRaises() == 1){
// one raise
if (checkHandForHSet(heroHand,21)){
board.setHeroActionOnTurn(HeroActionOnTurn.HAOT_RERAISE);
logger.log(Level.WARNING,"REASON: (RAISE) heroHand,21");
return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
}
}else{
if (checkHandForHSet(heroHand,22)){
board.setHeroActionOnTurn(HeroActionOnTurn.HAOT_RERAISE);
logger.log(Level.WARNING,"REASON: (RAISE) heroHand,22");
return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
}
}
logger.log(Level.WARNING,"REASON: (FOLD) nothing");
return new AnalystResult(UIReaction.UIR_ACTION_FOLD, "");
case MIDDLE_POSITION:
if (board.getNumOfRaises() == 0){
if (checkHandForHSet(heroHand,12)){
board.setHeroActionOnTurn(HeroActionOnTurn.HAOT_RAISE);
logger.log(Level.WARNING,"REASON: (RAISE) heroHand,12");
return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
}
}else
if (board.getNumOfRaises() == 1){
// one raise
if (checkHandForHSet(heroHand,21)) {
board.setHeroActionOnTurn(HeroActionOnTurn.HAOT_RERAISE);
logger.log(Level.WARNING,"REASON: (RAISE) heroHand,21");
return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
}
}else{
if (checkHandForHSet(heroHand,22)){
logger.log(Level.WARNING,"REASON: (RAISE) heroHand,22");
board.setHeroActionOnTurn(HeroActionOnTurn.HAOT_RERAISE);
return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
}
}
if (checkHandForHSet(heroHand,41) && FloatEx.gt4(bb * 4.1f, board.needAmountToCall())){
logger.log(Level.WARNING,"REASON: (CALL) heroHand,41");
return new AnalystResult(UIReaction.UIR_ACTION_CALL, "");
}
return new AnalystResult(UIReaction.UIR_ACTION_FOLD, "");
case LAST_POSITION:
if (board.getNumOfRaises() == 0){
if (checkHandForHSet(heroHand,13)){
logger.log(Level.WARNING,"REASON: (RAISE) heroHand,13");
board.setHeroActionOnTurn(HeroActionOnTurn.HAOT_RAISE);
return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
}
if (checkHandForHSet(heroHand,131) && limpersCount == 0){
logger.log(Level.WARNING,"REASON: (RAISE) heroHand,131.... limpers = 0");
return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
}
}else
if (board.getNumOfRaises() == 1){
// one raise
if (checkHandForHSet(heroHand,21)){
board.setHeroActionOnTurn(HeroActionOnTurn.HAOT_RERAISE);
logger.log(Level.WARNING,"REASON: (RAISE) heroHand,21");
return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
}
}else{
if (checkHandForHSet(heroHand,22)){
logger.log(Level.WARNING,"REASON: (RAISE) heroHand,22");
board.setHeroActionOnTurn(HeroActionOnTurn.HAOT_RERAISE);
return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
}
}
if (checkHandForHSet(heroHand,42) && FloatEx.gt4(bb * 4.1f, board.needAmountToCall())){
logger.log(Level.WARNING,"REASON: (RAISE) heroHand,42");
return new AnalystResult(UIReaction.UIR_ACTION_CALL, "");
}
logger.log(Level.WARNING,"REASON: (FOLD) nothing");
return new AnalystResult(UIReaction.UIR_ACTION_FOLD, "");
case BLINDS:
if (board.getNumOfRaises() == 0){
if (checkHandForHSet(heroHand,13)){
logger.log(Level.WARNING,"REASON: (RAISE) heroHand,13");
board.setHeroActionOnTurn(HeroActionOnTurn.HAOT_RAISE);
return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
}
if (checkHandForHSet(heroHand,141) && limpersCount <= 1){
logger.log(Level.WARNING,"REASON: (RAISE) heroHand,141");
board.setHeroActionOnTurn(HeroActionOnTurn.HAOT_RAISE);
return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
}
}else
if (board.getNumOfRaises() == 1){
if (board.getNextInGamePlayer(firstRaiserPosition) == board.getDealer() ||
board.getNextInGamePlayer(board.getNextInGamePlayer(firstRaiserPosition)) == board.getDealer() ||
firstRaiserPosition == board.getDealer() ||
board.getNextInGamePlayer(board.getDealer()) == firstRaiserPosition){
if (checkHandForHSet(heroHand,31)){
logger.log(Level.WARNING,"REASON: (RAISE) heroHand,31");
board.setHeroActionOnTurn(HeroActionOnTurn.HAOT_RERAISE);
return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
}
}
if (checkHandForHSet(heroHand,21)){
logger.log(Level.WARNING,"REASON: (RAISE) heroHand,21");
board.setHeroActionOnTurn(HeroActionOnTurn.HAOT_RERAISE);
return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
}
}else{
if (checkHandForHSet(heroHand,21)){
logger.log(Level.WARNING,"REASON: (RAISE) heroHand,21");
board.setHeroActionOnTurn(HeroActionOnTurn.HAOT_RERAISE);
return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
}
}
logger.log(Level.WARNING,"REASON: (FOLD) nothing");
return new AnalystResult(UIReaction.UIR_ACTION_FOLD, "");
default: System.err.println("�� ���������� �������");
break;
}
}else{
// check for resteal
boolean isResteal = false;
int anotherActivePos = -1;
int tempPosition = board.getHero();
if ( board.getHeroActionOnTurn() == HeroActionOnTurn.HAOT_RERAISE){
logger.log(Level.WARNING,"REASON: (ALL) on prev was reraise");
return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(board.getPlayers().get(board.getHero()).getStack()));
}
if (board.getActivePlayers() == 2){
anotherActivePos = board.getNextActivePlayer(board.getHero());
if(board.getPosition() == Position.LAST_POSITION || board.getPosition() == Position.BLINDS){
for(int i = 0; i<3; i++){
tempPosition = board.getNextInGamePlayer(tempPosition);
if (tempPosition == anotherActivePos){
isResteal = true;
break;
}
}
}
}
if (isResteal){
if (checkHandForHSet(heroHand,32)){
logger.log(Level.WARNING,"REASON: (RAISE) heroHand,32");
return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(board.getPlayers().get(board.getHero()).getStack()));
}
}
else{
if (checkHandForHSet(heroHand,23)){
logger.log(Level.WARNING,"REASON: (RAISE) heroHand,23");
if (board.getActivePlayers() == 2)
return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(board.getPlayers().get(board.getHero()).getStack()));
else
return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
}
}
logger.log(Level.WARNING,"REASON: (FOLD) nothing");
return new AnalystResult(UIReaction.UIR_ACTION_FOLD, "");
}
return null;
}
@Override
public AnalystResult getFlopReaction(DataForStrategy dfs) {
AvailableCombinations availcomb = new AvailableCombinations(dfs.getCurrentBoard().getPlayingCards());
AvailableCombinationsTools act = new AvailableCombinationsTools(availcomb);
Hand hand = new Hand(dfs.getCurrentBoard().getPlayingCards().getPlayerCards());
Combination topCombination = act.getTopCombination();
Flush flushDraw = act.analyzeFlush(true);
Straight straightDraw = act.analyzeStraight(true);
if (availcomb.getFlushDraws() != null && availcomb.getFlushDraws().size() != 0 &&
flushDraw == null)
if (topCombination.getCombinationValue() < new Flush().getCombinationValue())
topCombination = null;
if (availcomb.getStraightOesds() != null && availcomb.getStraightOesds().size() != 0 &&
straightDraw == null)
if (topCombination.getCombinationValue() < new Straight().getCombinationValue())
topCombination = null;
topCombination = act.cutNotHeroCombination(topCombination);
if (topCombination != null){
if (topCombination instanceof HighCard)
topCombination = null;
if (topCombination instanceof Flush)
topCombination = act.analyzeFlush(false);
else
if (topCombination instanceof Straight)
topCombination = act.analyzeStraight(false);
if (topCombination instanceof TwoPairs)
topCombination = act.analyzeTwoPair(topCombination,true);
}
Board board = dfs.getCurrentBoard();
Board boardPrev = dfs.getPrevBoard();
/*
if (!heroName.equals(board.getPlayers().get(board.getHero()).getName().trim())){
return new AnalystResult(UIReaction.UIR_ACTION_FOLD, "ONLYFOLD");
}*/
System.out.println(board.getCurrentRound()+ ": " + topCombination);
logger.log(Level.WARNING,"StrDraw: " + straightDraw);
logger.log(Level.WARNING,"FlushDraw: " + flushDraw);
// if on previous round hero stack was calculated incorrectly
if (board.getPlayers().get(board.getHero()).getStack() < board.getBigBlind() * 2)
return new AnalystResult(UIReaction.UIR_ACTION_RAISE , StringEx.float2str2(dfs.getPlayerMoney()));
boolean wasRaiseOnPrevRound = false;
boolean wasRaiseBeforeHero = false;
boolean isFirstCircle = false;
boolean wasRaiseHero = false;
wasRaiseOnPrevRound = !(FloatEx.equals4(boardPrev.getPlayers().get(boardPrev.getHero()).getBet(), boardPrev.getBigBlind()));
wasRaiseBeforeHero = !(FloatEx.equals4(board.getTotal(),0));
wasRaiseHero = !(FloatEx.equals4(board.getPlayers().get(board.getHero()).getBet(),0));
isFirstCircle = !(FloatEx.equals4(board.getPlayers().get(board.getHero()).getBet(),0)) ;
if (wasRaiseOnPrevRound){
if (topCombination instanceof Pair)
topCombination = act.analyzePair(topCombination,true,true,CardFace.FOUR,CardFace.JACK);
}else
{
if (topCombination instanceof Pair)
topCombination = act.analyzePair(topCombination,false,true,CardFace.JACK,CardFace.JACK);
}
float heroMoney = dfs.getPlayerMoney();
float total = dfs.getTotalBank();
float raiseAmount = 0f;
float koeff = 2.0f/3.0f;
//кто-то ререйзнул
List<CardValue> cardvalues;
if (wasRaiseHero ){
if (dfs.getPlayerMoney() > board.getPlayers().get(board.getHero()).getBet()){
if (availcomb.getAllCards().contains(new Card(Suit.clubs, CardFace.ACE)) ||
availcomb.getAllCards().contains(new Card(Suit.diamonds, CardFace.ACE)) ||
availcomb.getAllCards().contains(new Card(Suit.spades, CardFace.ACE)) ||
availcomb.getAllCards().contains(new Card(Suit.hearts, CardFace.ACE))){
if (topCombination instanceof Pair){
// if pair is middle && Ace exists => fold
//cardvalues = act.getCardValuesFromComb(topCombination, hand);
//if (cardvalues.get(0).getCard().getFace() != CardFace.ACE)
if (hand.getHandCards()[0].getFace() != CardFace.ACE &&
hand.getHandCards()[1].getFace() != CardFace.ACE)
topCombination = null;
}
}
}
}
if (wasRaiseBeforeHero){
raiseAmount = dfs.getPlayerMoney();
}
else
raiseAmount = koeff * total;
if (raiseAmount > dfs.getPlayerMoney() / 2)
raiseAmount = dfs.getPlayerMoney();
// all-in (no raises, low stack)
if (total - board.getTotal() > dfs.getPlayerMoney() * 2 && !wasRaiseBeforeHero){
logger.log(Level.WARNING,"all-in (no raises, low stack)");
return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(dfs.getPlayerMoney()));
}
if (board.getActivePlayers() == 2){
if (FloatEx.equals4(board.getTotal(),0)){
logger.log(Level.WARNING,"RAISE->2 players");
return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
}else{
if (topCombination != null || flushDraw != null || straightDraw != null){
logger.log(Level.WARNING,"RAISE->topCombination != null || flushDraw != null || straightDraw != null");
return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
}
else
return new AnalystResult(UIReaction.UIR_ACTION_FOLD, "");
}
}
if (wasRaiseOnPrevRound){
if (topCombination != null || flushDraw != null || straightDraw != null){
return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
}
}else{
if (topCombination != null || flushDraw != null || straightDraw != null){
return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
}
}
return new AnalystResult(UIReaction.UIR_ACTION_FOLD, "");
}
@Override
public AnalystResult getTurnReaction(DataForStrategy dfs) {
AvailableCombinations availcomb = new AvailableCombinations(dfs.getCurrentBoard().getPlayingCards());
AvailableCombinationsTools act = new AvailableCombinationsTools(availcomb);
Hand hand = new Hand(dfs.getCurrentBoard().getPlayingCards().getPlayerCards());
Combination topCombination = act.getTopCombination();
Flush flushDraw = act.analyzeFlush(true);
Straight straightDraw = act.analyzeStraight(true);
if (availcomb.getFlushDraws() != null && availcomb.getFlushDraws().size() != 0 &&
flushDraw == null)
if (topCombination.getCombinationValue() < new Flush().getCombinationValue())
topCombination = null;
if (availcomb.getStraightOesds() != null && availcomb.getStraightOesds().size() != 0 &&
straightDraw == null)
if (topCombination.getCombinationValue() < new Straight().getCombinationValue())
topCombination = null;
topCombination = act.cutNotHeroCombination(topCombination);
if (topCombination != null){
if (topCombination instanceof HighCard)
topCombination = null;
if (topCombination instanceof Flush)
topCombination = act.analyzeFlush(false);
else
if (topCombination instanceof Straight)
topCombination = act.analyzeStraight(false);
}
Board board = dfs.getCurrentBoard();
Board boardPrev = dfs.getPrevBoard();
/*
if (!heroName.equals(board.getPlayers().get(board.getHero()).getName().trim())){
return new AnalystResult(UIReaction.UIR_ACTION_FOLD, "ONLYFOLD");
}
*/
// if on previous round hero stack was calculated incorrectly
if (board.getPlayers().get(board.getHero()).getStack() < board.getBigBlind() * 2)
return new AnalystResult(UIReaction.UIR_ACTION_RAISE , StringEx.float2str2(dfs.getPlayerMoney()));
boolean wasRaiseOnPrevRound = false;
boolean wasRaiseBeforeHero = false;
wasRaiseOnPrevRound = !(FloatEx.equals4(boardPrev.getPlayers().get(boardPrev.getHero()).getBet(), boardPrev.getBigBlind()));
wasRaiseBeforeHero = !(FloatEx.equals4(board.getTotal(),0));
if (topCombination instanceof Pair)
topCombination = act.analyzePair(topCombination,true,true,CardFace.FOUR,CardFace.JACK);
float total = dfs.getTotalBank();
float raiseAmount = 0f;
float koeff = 1.0f;
/*
if(topCombination == null && (flushDraw != null || straightDraw != null))
koeff = 2.0f/3.0f;
*/
if (wasRaiseBeforeHero){
raiseAmount = dfs.getPlayerMoney();
}
else
raiseAmount = koeff * total;
if (raiseAmount > dfs.getPlayerMoney() / 2)
raiseAmount = dfs.getPlayerMoney();
// all-in (no raises, low stack)
if (total - board.getTotal() > dfs.getPlayerMoney() * 4 && !wasRaiseBeforeHero)
return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(dfs.getPlayerMoney()));
if (topCombination != null || flushDraw != null || straightDraw != null){
return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
}
return new AnalystResult(UIReaction.UIR_ACTION_FOLD, "");
}
@Override
public AnalystResult getRiverReaction(DataForStrategy dfs) {
AvailableCombinations availcomb = new AvailableCombinations(dfs.getCurrentBoard().getPlayingCards());
AvailableCombinationsTools act = new AvailableCombinationsTools(availcomb);
Hand hand = new Hand(dfs.getCurrentBoard().getPlayingCards().getPlayerCards());
Combination topCombination = act.getTopCombination();
Flush flushDraw = act.analyzeFlush(true);
Straight straightDraw = act.analyzeStraight(true);
if (availcomb.getFlushDraws() != null && availcomb.getFlushDraws().size() != 0 &&
flushDraw == null)
if (topCombination.getCombinationValue() < new Flush().getCombinationValue())
topCombination = null;
if (availcomb.getStraightOesds() != null && availcomb.getStraightOesds().size() != 0 &&
straightDraw == null)
if (topCombination.getCombinationValue() < new Straight().getCombinationValue())
topCombination = null;
topCombination = act.cutNotHeroCombination(topCombination);
if (topCombination != null){
if (topCombination instanceof HighCard)
topCombination = null;
if (topCombination instanceof Flush)
topCombination = act.analyzeFlush(false);
else
if (topCombination instanceof Straight)
topCombination = act.analyzeStraight(false);
}
Board board = dfs.getCurrentBoard();
Board boardPrev = dfs.getPrevBoard();
/*
if (!heroName.equals(board.getPlayers().get(board.getHero()).getName().trim())){
return new AnalystResult(UIReaction.UIR_ACTION_FOLD, "ONLYFOLD");
}
*/
// if on previous round hero stack was calculated incorrectly
if (board.getPlayers().get(board.getHero()).getStack() < board.getBigBlind() * 2)
return new AnalystResult(UIReaction.UIR_ACTION_RAISE , StringEx.float2str2(dfs.getPlayerMoney()));
boolean wasRaiseOnPrevRound = false;
boolean wasRaiseBeforeHero = false;
wasRaiseOnPrevRound = !(FloatEx.equals4(boardPrev.getPlayers().get(boardPrev.getHero()).getBet(), boardPrev.getBigBlind()));
wasRaiseBeforeHero = !(FloatEx.equals4(board.getTotal(),0));
if (topCombination instanceof Pair)
topCombination = act.analyzePair(topCombination,true,true,CardFace.FOUR,CardFace.JACK);
float total = dfs.getTotalBank();
float raiseAmount = 0f;
float koeff = 1.0f;
if (wasRaiseBeforeHero){
raiseAmount = dfs.getPlayerMoney();
}
else
raiseAmount = koeff * total;
if (raiseAmount > dfs.getPlayerMoney() / 2)
raiseAmount = dfs.getPlayerMoney();
// all-in (no raises, low stack)
if (total - board.getTotal() > dfs.getPlayerMoney() * 4 && !wasRaiseBeforeHero)
return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(dfs.getPlayerMoney()));
if (topCombination != null){
return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
}
return new AnalystResult(UIReaction.UIR_ACTION_FOLD, "");
}
}