Package com.poker.analyst.strategy.temp

Source Code of com.poker.analyst.strategy.temp.SSSStrategy1

package com.poker.analyst.strategy.temp;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.poker.analyst.AnalystResult;
import com.poker.analyst.combination.Combination;
import com.poker.analyst.combination.CombinationType;
import com.poker.analyst.combination.Pair;
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.strategy.DataForStrategy;
import com.poker.analyst.strategy.Strategy;
import com.poker.ui.robot.reaction.UIReaction;
import com.poker.utils.FloatEx;
import com.poker.utils.StringEx;

public class SSSStrategy1 extends Strategy {

 
  public SSSStrategy1(String heroName) {

        super(heroName);
        // TODO Auto-generated constructor stub
    }

    public boolean maySitToTable(DataForStrategy dfs){   
    boolean result = true;
   
    Board board = dfs.getCurrentBoard();
   
    int countSssPlayers = 0;
    for (Player player: board.getPlayers()){
      if (FloatEx.gt4( board.getPlayers().get(board.getHero()).getStack(),player.getStack())){
        countSssPlayers++;
      }
    }
    if (countSssPlayers > 5){
      result = false;
      System.err.println("SSS players > 5");   
    }     
   
    return result;
  }
 
  public ActionBeforePlay getPreparedAction(DataForStrategy dfs){
    Board board = dfs.getCurrentBoard();
    // CLOSEWINDOW   
    if (FloatEx.gt4(board.getPlayers().get(board.getHero()).getStack(),1.25f * board.getBigBlind() * 30)){
      System.err.println("hero have mush money");
      return ActionBeforePlay.ABP_CLOSEWINDOW;
    }

    if (board.getInGamePlayers() < 7){
      System.err.println("numPlayers < 7");
      return ActionBeforePlay.ABP_CLOSEWINDOW;
    }
   
    int countSssPlayers = 0;
    for (Player player: board.getPlayers()){
      if (FloatEx.gt4(30 * board.getBigBlind(),player.getStack())){
        countSssPlayers++;
      }
    }
    if (countSssPlayers > 5){
      System.err.println("SSS players > 5");
      return ActionBeforePlay.ABP_CLOSEWINDOW;
    }     
    return null;
  }
 
  @Override
  public AnalystResult getReaction(DataForStrategy dfs) {
    // TODO SSS strategy
    /*
    System.out.println("c_round: " + dfs.getCurrentRound());
    System.out.println("toCall : " + dfs.getCurrentBoard().needAmountToCall());
    System.out.println("total  : " + FloatEx.cutFloat2(dfs.getTotalBank()));
    System.out.println("plMoney: " + FloatEx.cutFloat2(dfs.getPlayerMoney()));
    System.out.println("posit  : " + dfs.getCurrentBoard().getPosition());
  //  System.out.println("posit-r: " + dfs.getCurrentBoard().getPosition().getRelative());
    */
    return super.getReaction(dfs);
   
   
   
  }

  @Override
  public AnalystResult isNeedRebuy(DataForStrategy dfs) {
    // TODO [SSS] need rebuy
    return new AnalystResult(null, null);
  }

  @Override
  public AnalystResult getPreFlopReaction(DataForStrategy dfs) {
   
   
    AnalystResult analystResult = null;
   
    Board board = dfs.getCurrentBoard();
    float bbValue     = board.getBigBlind();
    float sbValue     = board.getSmallBlind();
    float leveledAmount = board.getLeveledAmount();
    float bNeedToCallValue = board.needAmountToCall();
   
    float raiseForLimpers  = 0;
   
    Hand heroHand = new Hand();
    heroHand.setHandCards(board.getPlayingCards().getPlayerCards());
   
       
   
    // TODO [SSS-PF] find limpers count;       
    int   limpersCount  = -1
    int   raisersBefCount  = -1;
   
    for (Player player: board.getPlayers()){
      if (FloatEx.equals4(player.getBet() - bbValue,0f))
        limpersCount ++;
    }
   
    raiseForLimpers = FloatEx.cutFloat2(new Float(1.1 * bbValue *(4 + limpersCount) ) );   
   
    boolean isFirstCircle = true;
    if (board.getPlayers().get(board.getHero()).getName().trim() == "")
      isFirstCircle = true;
    else
      isFirstCircle = false;
   
    int firstPlayerRaisePos = -1;
    if (isFirstCircle) {
      raisersBefCount = board.getNumOfRaises();
      for (int i = 0; i< board.getPlayers().size() ; i++){       
        if (firstPlayerRaisePos == -1)
          firstPlayerRaisePos = i;
      }
     
      if (raisersBefCount == 0){
        int nSet = 0;
       
        if (board.getHero() == board.getNextInGamePlayer(board.getNextInGamePlayer(board.getDealer())) &&
            limpersCount == 1 && checkHandForHSet(heroHand,11))
          return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseForLimpers));
       
       
        if (board.getHero() == board.getDealer() && limpersCount == 0 && checkHandForHSet(heroHand,9))
          return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseForLimpers));
       
        if (board.getHero() == board.getNextInGamePlayer(board.getDealer()) && limpersCount == 0 && checkHandForHSet(heroHand,10))
          return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseForLimpers));
        
        switch (board.getPosition()) {
          case EARLY_POSITION:   nSet = 1; break;
          case MIDDLE_POSITION:  nSet = 2; break;
          case LAST_POSITION:     nSet = 3; break;
          case BLINDS:       nSet = 3; break;
 
          default: System.err.println("ERROR on count raise with limpers");
            break;
        }  
        if (checkHandForHSet(heroHand,nSet)){
          if (dfs.getPlayerMoney() > raiseForLimpers)
            return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseForLimpers));
          else
            return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(dfs.getPlayerMoney()));
        }else{
          if (FloatEx.equals4(bNeedToCallValue,0f))
            return new AnalystResult(UIReaction.UIR_ACTION_CHECK, "");
          else
            return new AnalystResult(UIReaction.UIR_ACTION_FOLD, "");
        }                     
      }else
      if (raisersBefCount == 1){
        if (checkHandForHSet(heroHand,1)){
          return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(dfs.getPlayerMoney()));
        }       
        // TODO analyze for re steal
        // ReSteal may be when I'm at bb & Steel at lastPos
        int tmpint = 0;
                     
        if (board.getNextInGamePlayer(board.getNextInGamePlayer(board.getDealer())) == board.getHero()){         
         
          tmpint = firstPlayerRaisePos;
          for (int i = 0; i<3; i++)
          {
            tmpint = board.getNextInGamePlayer(tmpint);
            if (tmpint == board.getHero() && checkHandForHSet(heroHand,2))
              return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(dfs.getPlayerMoney()));
          }
        }       
      }else{
        if (checkHandForHSet(heroHand,5)){         
          return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(dfs.getPlayerMoney()));
        }               
      }       
    }
    else {
      if (checkHandForHSet(heroHand,6)){         
        return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(dfs.getPlayerMoney()));
      }     
    }
             
    if (limpersCount < 0)
      System.err.println("ERROR in counting limpers");
       
    return new AnalystResult(UIReaction.UIR_ACTION_FOLD, "");
  }

  @Override
  public AnalystResult getFlopReaction(DataForStrategy dfs) {
  /*  final CombinationMatcher matcher = new CombinationMatcher();              
        Combination combination = matcher.analyzeCombination(dfs.getCurrentBoard().getPlayingCards(), dfs.getCurrentRound());       
       
       
        Board board = dfs.getCurrentBoard();
        Board boardPrev = dfs.getPrevBoard();
       
        if (board.getPlayers().get(board.getHero()).getStack() < board.getBigBlind() * 2)
      return new AnalystResult(UIReaction.UIR_ACTION_RAISE , StringEx.float2str2(dfs.getPlayerMoney()));
   
        Hand heroHand = new Hand();
    heroHand.setHandCards(board.getPlayingCards().getPlayerCards());
        if (board.getHero() == board.getNextInGamePlayer(board.getNextInGamePlayer(board.getDealer())) && !checkHandForHSet(heroHand,11)){
          return new AnalystResult(UIReaction.UIR_ACTION_FOLD, "");
        }
           
        // 0 = nothing
        // 1 =  low pair
        // 2 =  middle pair bad kicker
        // 3 =  middle pair good kicker
        // 4 =  top pair bad kicker
        // 5 =  top pair good kicker
        // 6 =  high pair pocket
        // 7 =  comb> 3;   
       
        int solve = -1;
       
        boolean flushDraw = false;
        boolean straightDraw = false;
       
        flushDraw    = (matcher.getFlushDraw() != null && matcher.getFlushDraw().isDraw());
       
        straightDraw = (matcher.getStraightDraw() != null && matcher.getStraightDraw().isOESD());
       
        System.out.println("staight " + straightDraw);
        System.out.println("flush " + flushDraw);
       
       
       
        System.out.print(combination + " ; sd= " + straightDraw + " ; fd ="+ flushDraw );
       
        Card tmpcard = null;       
        if (combination.getCombinationValue() >= 2){
          solve = 7;
        }
        else {         
        if (combination.getCombinationValue() == 1){
          if (combination instanceof Pair){
            Pair pair = (Pair)combination;
            if (pair.isFromHeroCard() || pair.isPoketPair()){
              if (pair.getPairType() == CombinationType.HIGH )
                solve = 6;             
              else              
              if (pair.getPairType() == CombinationType.MIDDLE || pair.getPairType() == CombinationType.TOP){
                boolean goodkicker = false;
                // TODO  handle kicker
                if (pair.isPoketPair())
                  goodkicker = false;
                else{
                  Card[] heroCards = board.getPlayingCards().getPlayerCards();
                  for (int i = 0; i< heroCards.length; i++){
                    if (heroCards[i].getFace() != pair.getPairFace())
                      tmpcard = heroCards[i];
                  }                 
                 
                  if(tmpcard == null)
                    System.err.println("����� �� ����� ���� �������");
                  else
                   
                    if (pair.getPairType() == CombinationType.MIDDLE){
                      if (tmpcard.getFace().getSerialNumber() >= CardFace.JACK.getSerialNumber() )
                        goodkicker = true;
                    }
                    else{
                      if (tmpcard.getFace().getSerialNumber() >= pair.getPairFace().getSerialNumber() )
                        goodkicker = true;
                    }
                }
                         
                if (pair.getPairType() == CombinationType.MIDDLE || pair.getPairType() == CombinationType.TOP){
                  if (goodkicker)
                    solve = 3;
                  else
                    solve = 2;
                }else{
                  if (goodkicker)
                    solve = 5;
                  else
                    solve = 4;
                }
                                               
              }
              else{
                solve = 1;
              }               
            }   
          }
        }
        else
      {
          solve = 0;
        }
        }      
       
        System.out.println("solve : " + solve);
      
        boolean wasRaiseOnPrevRound = false;
        boolean wasRaiseBeforeHero  = false;
       
       
        wasRaiseOnPrevRound   = !(FloatEx.equals4(boardPrev.getPlayers().get(boardPrev.getHero()).getBet(), boardPrev.getBigBlind()));
        wasRaiseBeforeHero    = !(FloatEx.equals4(board.getTotal(),0));
       
        float heroMoney = dfs.getPlayerMoney();
        float total    = dfs.getTotalBank();
       
        boolean isNeedAllIn =  false;
        boolean bCondition = false;
        boolean GoodCombination = false;
       
        if (wasRaiseOnPrevRound)
          bCondition = solve >= 3 || flushDraw || straightDraw;                 
        else
          bCondition = solve >= 5;
       
        float koeff = 2.0f/3.0f;
        if (solve >= 7)
          koeff = 1;
        
      if (bCondition){
        if (!wasRaiseBeforeHero ){
          if (dfs.getTotalBank() * koeff > dfs.getPlayerMoney() / 2)
            return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(dfs.getPlayerMoney()));
          else{
            return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(dfs.getTotalBank() * koeff));
          }
        }else{
          return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(dfs.getPlayerMoney()));         
        }         
      }else{
        if ((dfs.getTotalBank()  - board.getTotal()) > 1.5 * dfs.getPlayerMoney() )
        return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(dfs.getPlayerMoney()));
       
        if (board.getActivePlayers() == 2){         
          if (!wasRaiseBeforeHero)
            return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(koeff * dfs.getTotalBank()));
          else
            return new AnalystResult(UIReaction.UIR_ACTION_FOLD, "");
        }               
      }
      */
      return new AnalystResult(UIReaction.UIR_ACTION_FOLD, "");
     
  }

  @Override
  public AnalystResult getTurnReaction(DataForStrategy dfs) {
    /*
    final CombinationMatcher matcher = new CombinationMatcher();              
        Combination combination = matcher.analyzeCombination(dfs.getCurrentBoard().getPlayingCards(), dfs.getCurrentRound());       
       
       
        Board board = dfs.getCurrentBoard();
        Board boardPrev = dfs.getPrevBoard();
       
        if (board.getPlayers().get(board.getHero()).getStack() < board.getBigBlind() * 2)
      return new AnalystResult(UIReaction.UIR_ACTION_RAISE , StringEx.float2str2(dfs.getPlayerMoney()));
   
        Hand heroHand = new Hand();
    heroHand.setHandCards(board.getPlayingCards().getPlayerCards());
        if (board.getHero() == board.getNextInGamePlayer(board.getNextInGamePlayer(board.getDealer())) && !checkHandForHSet(heroHand,11)){
          return new AnalystResult(UIReaction.UIR_ACTION_FOLD, "");
        }
        // 0 = nothing
        // 1 =  low pair
        // 2 =  middle pair bad kicker
        // 3 =  middle pair good kicker
        // 4 =  top pair bad kicker
        // 5 =  top pair good kicker
        // 6 =  high pair pocket
        // 7 =  comb> 3;   
       
        int solve = -1;
       
        boolean flushDraw = false;
        boolean straightDraw = false;
       
        flushDraw    = (matcher.getFlushDraw() != null && matcher.getFlushDraw().isDraw());
       
        straightDraw = (matcher.getStraightDraw() != null && matcher.getStraightDraw().isOESD());
       
        System.out.println("staight " + straightDraw);
        System.out.println("flush " + flushDraw);
       
       
       
        System.out.print(combination + " ; sd= " + straightDraw + " ; fd ="+ flushDraw );
       
        Card tmpcard = null;       
        if (combination.getCombinationValue() >= 2){
          solve = 7;
        }
        else {         
        if (combination.getCombinationValue() == 1){
          if (combination instanceof Pair){
            Pair pair = (Pair)combination;
            if (pair.isFromHeroCard() || pair.isPoketPair()){
              if (pair.getPairType() == CombinationType.HIGH )
                solve = 6;             
              else              
              if (pair.getPairType() == CombinationType.MIDDLE || pair.getPairType() == CombinationType.TOP){
                boolean goodkicker = false;
                // TODO  handle kicker
                if (pair.isPoketPair())
                  goodkicker = false;
                else{
                  Card[] heroCards = board.getPlayingCards().getPlayerCards();
                  for (int i = 0; i< heroCards.length; i++){
                    if (heroCards[i].getFace() != pair.getPairFace())
                      tmpcard = heroCards[i];
                  }                 
                 
                  if(tmpcard == null)
                    System.err.println("����� �� ����� ���� �������");
                  else
                   
                    if (pair.getPairType() == CombinationType.MIDDLE){
                      if (tmpcard.getFace().getSerialNumber() >= CardFace.JACK.getSerialNumber() )
                        goodkicker = true;
                    }
                    else{
                      if (tmpcard.getFace().getSerialNumber() >= pair.getPairFace().getSerialNumber() )
                        goodkicker = true;
                    }
                }
                         
                if (pair.getPairType() == CombinationType.MIDDLE || pair.getPairType() == CombinationType.TOP){
                  if (goodkicker)
                    solve = 3;
                  else
                    solve = 2;
                }else{
                  if (goodkicker)
                    solve = 5;
                  else
                    solve = 4;
                }
                                               
              }
              else{
                solve = 1;
              }               
            }   
          }
        }
        else
      {
          solve = 0;
        }
        }      
       
        System.out.println("solve : " + solve);
      
        boolean wasRaiseOnPrevRound = false;
        boolean wasRaiseBeforeHero  = false;
       
       
        wasRaiseOnPrevRound   = !(FloatEx.equals4(boardPrev.getPlayers().get(boardPrev.getHero()).getBet(), boardPrev.getBigBlind()));
        wasRaiseBeforeHero    = !(FloatEx.equals4(board.getTotal(),0));
       
        float heroMoney = dfs.getPlayerMoney();
        float total    = dfs.getTotalBank();
       
        boolean isNeedAllIn =  false;
        boolean bCondition = false;
       
        if (wasRaiseOnPrevRound)
          bCondition = solve >= 3 ;//|| flushDraw || straightDraw;                 
        else
          bCondition = solve >= 5;
        
        float koeff = 2.0f/3.0f;
        if (solve >= 7)
          koeff = 1;
           
      if (bCondition){
        if (!wasRaiseBeforeHero ){
          if (dfs.getTotalBank() * koeff > dfs.getPlayerMoney() / 2)
            return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(dfs.getPlayerMoney()));
          else{
            return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(dfs.getTotalBank() * koeff));
          }
        }else{
          return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(dfs.getPlayerMoney()));
        }         
      }else{
        if ((dfs.getTotalBank()  - board.getTotal()) > 1.5 * dfs.getPlayerMoney() )
        return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(dfs.getPlayerMoney()));
        /*
        if (wasRaiseOnPrevRound && board.getActivePlayers() == 2){
         
          if (!wasRaiseBeforeHero)
            return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(dfs.getTotalBank() * 2 / 3));
          else
            return new AnalystResult(UIReaction.UIR_ACTION_FOLD, "");
        } */              
    //  }
     
      return new AnalystResult(UIReaction.UIR_ACTION_FOLD, "");
    /*
    Board boardPrev = dfs.getPrevBoard();
    Board board     = dfs.getCurrentBoard();
    Card tmpcard = null;
    boolean wasRaiseOnPrevRound = false;       
   
    if (board.getPlayers().get(board.getHero()).getStack() < board.getBigBlind() * 2)
      return new AnalystResult(UIReaction.UIR_ACTION_RAISE , StringEx.float2str2(dfs.getPlayerMoney()));
     
       
    final CombinationMatcher matcher = new CombinationMatcher();              
        Combination combination = matcher.analyzeCombination(dfs.getCurrentBoard().getPlayingCards(), dfs.getCurrentRound());       
       
       
        wasRaiseOnPrevRound   = !(FloatEx.equals4(boardPrev.getPlayers().get(boardPrev.getHero()).getBet(), 0));       
    if (!wasRaiseOnPrevRound)
      if (combination.getCombinationValue() >= 3)
        return new AnalystResult(UIReaction.UIR_ACTION_RAISE , StringEx.float2str2(dfs.getPlayerMoney()));
      else
        return new AnalystResult(UIReaction.UIR_ACTION_FOLD , "");
   
    if (combination.getCombinationValue() >=2)
      return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(dfs.getPlayerMoney()));
    else{
      if (combination.getCombinationValue() == 1){
        if (combination instanceof Pair){
          Pair pair = (Pair)combination;
          if (pair.isFromHeroCard || pair.isPoketPair){
            if (pair.pairType == TYPE.HIGH)
              return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(dfs.getPlayerMoney()));
            else {
              if (pair.pairType == TYPE.TOP ){
                  // TODO  handle kicker
                if (pair.isPoketPair)
                  return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(dfs.getPlayerMoney()));
               
                Card[] heroCards = board.getPlayingCards().getPlayerCards();
                  for (int i = 0; i< heroCards.length; i++){
                    if (heroCards[i].getFace() != pair.pairFace)
                      tmpcard = heroCards[i];
                  }                 
                 
                  if(tmpcard == null)
                    System.err.println("����� �� ����� ���� �������");
                  else
                  {
                    if (tmpcard.getFace().getSerialNumber() >= CardFace.JACK.getSerialNumber() )
                      return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(dfs.getPlayerMoney()));
                  }
              }
            }
          }
        }
       
      }
      return new AnalystResult(UIReaction.UIR_ACTION_FOLD , StringEx.float2str2(dfs.getPlayerMoney()));
    }*/
     
  }

  @Override
  public AnalystResult getRiverReaction(DataForStrategy dfs) {
    /*
    final CombinationMatcher matcher = new CombinationMatcher();              
        Combination combination = matcher.analyzeCombination(dfs.getCurrentBoard().getPlayingCards(), dfs.getCurrentRound());       
       
       
        Board board = dfs.getCurrentBoard();
        Board boardPrev = dfs.getPrevBoard();
       
        if (board.getPlayers().get(board.getHero()).getStack() < board.getBigBlind() * 2)
      return new AnalystResult(UIReaction.UIR_ACTION_RAISE , StringEx.float2str2(dfs.getPlayerMoney()));
   
        Hand heroHand = new Hand();
    heroHand.setHandCards(board.getPlayingCards().getPlayerCards());
        if (board.getHero() == board.getNextInGamePlayer(board.getNextInGamePlayer(board.getDealer())) && !checkHandForHSet(heroHand,11)){
          return new AnalystResult(UIReaction.UIR_ACTION_FOLD, "");
        }
        // 0 = nothing
        // 1 =  low pair
        // 2 =  middle pair bad kicker
        // 3 =  middle pair good kicker
        // 4 =  top pair bad kicker
        // 5 =  top pair good kicker
        // 6 =  high pair pocket
        // 7 =  comb> 3;   
       
        int solve = -1;
       
        boolean flushDraw = false;
        boolean straightDraw = false;
       
        flushDraw    = (matcher.getFlushDraw() != null && matcher.getFlushDraw().isDraw());
       
        straightDraw = (matcher.getStraightDraw() != null && matcher.getStraightDraw().isOESD());
       
        System.out.println("staight " + straightDraw);
        System.out.println("flush " + flushDraw);
       
       
       
        System.out.print(combination + " ; sd= " + straightDraw + " ; fd ="+ flushDraw );
       
        Card tmpcard = null;       
        if (combination.getCombinationValue() >= 2){
          solve = 7;
        }
        else {         
        if (combination.getCombinationValue() == 1){
          if (combination instanceof Pair){
            Pair pair = (Pair)combination;
            if (pair.isFromHeroCard() || pair.isPoketPair()){
              if (pair.getPairType() == CombinationType.HIGH )
                solve = 6;             
              else              
              if (pair.getPairType() == CombinationType.MIDDLE || pair.getPairType() == CombinationType.TOP){
                boolean goodkicker = false;
                // TODO  handle kicker
                if (pair.isPoketPair())
                  goodkicker = false;
                else{
                  Card[] heroCards = board.getPlayingCards().getPlayerCards();
                  for (int i = 0; i< heroCards.length; i++){
                    if (heroCards[i].getFace() != pair.getPairFace())
                      tmpcard = heroCards[i];
                  }                 
                 
                  if(tmpcard == null)
                    System.err.println("����� �� ����� ���� �������");
                  else
                   
                    if (pair.getPairType() == CombinationType.MIDDLE){
                      if (tmpcard.getFace().getSerialNumber() >= CardFace.JACK.getSerialNumber() )
                        goodkicker = true;
                    }
                    else{
                      if (tmpcard.getFace().getSerialNumber() >= pair.getPairFace().getSerialNumber() )
                        goodkicker = true;
                    }
                }
                         
                if (pair.getPairType() == CombinationType.MIDDLE || pair.getPairType() == CombinationType.TOP){
                  if (goodkicker)
                    solve = 3;
                  else
                    solve = 2;
                }else{
                  if (goodkicker)
                    solve = 5;
                  else
                    solve = 4;
                }
                                               
              }
              else{
                solve = 1;
              }               
            }   
          }
        }
        else
      {
          solve = 0;
        }
        }      
      
        System.out.println("solve : " + solve);
      
        boolean wasRaiseOnPrevRound = false;
        boolean wasRaiseBeforeHero  = false;
       
       
        wasRaiseOnPrevRound   = !(FloatEx.equals4(boardPrev.getPlayers().get(boardPrev.getHero()).getBet(), boardPrev.getBigBlind()));
        wasRaiseBeforeHero    = !(FloatEx.equals4(board.getTotal(),0));
       
        float heroMoney = dfs.getPlayerMoney();
        float total    = dfs.getTotalBank();
       
        boolean isNeedAllIn =  false;
        boolean bCondition = false;
       
        if (wasRaiseOnPrevRound)
          bCondition = solve >= 3 ;//|| flushDraw || straightDraw;                 
        else
          bCondition = solve >= 5;
         
         float koeff = 2.0f/3.0f;
        if (solve >= 7)
          koeff = 1;
      if (bCondition){
        if (!wasRaiseBeforeHero ){
          if (dfs.getTotalBank() * koeff > dfs.getPlayerMoney() / 2)
            return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(dfs.getPlayerMoney()));
          else{
            return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(dfs.getTotalBank() * koeff));
          }
        }else{
          return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(dfs.getPlayerMoney()));
        }         
      }else{
        if ((dfs.getTotalBank()  - board.getTotal()) > 1.5 * dfs.getPlayerMoney() )
        return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(dfs.getPlayerMoney()));
        /*
        if (wasRaiseOnPrevRound && board.getActivePlayers() == 2){
         
          if (!wasRaiseBeforeHero)
            return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(dfs.getTotalBank() * 2 / 3));
          else
            return new AnalystResult(UIReaction.UIR_ACTION_FOLD, "");
        } */              
    //  }
     
      return new AnalystResult(UIReaction.UIR_ACTION_FOLD, "");
     
    /*Board boardPrev = dfs.getPrevBoard();
    Board board     = dfs.getCurrentBoard();
    Card tmpcard = null;
    boolean wasRaiseOnPrevRound = false;       
       
    if (board.getPlayers().get(board.getHero()).getStack() < board.getBigBlind() * 2)
      return new AnalystResult(UIReaction.UIR_ACTION_RAISE , StringEx.float2str2(dfs.getPlayerMoney()));
   
   
    final CombinationMatcher matcher = new CombinationMatcher();              
        Combination combination = matcher.analyzeCombination(dfs.getCurrentBoard().getPlayingCards(), dfs.getCurrentRound());       
       
       
        wasRaiseOnPrevRound   = !(FloatEx.equals4(boardPrev.getPlayers().get(boardPrev.getHero()).getBet(), 0));       
    if (!wasRaiseOnPrevRound)
      if (combination.getCombinationValue() >= 3)
        return new AnalystResult(UIReaction.UIR_ACTION_RAISE , StringEx.float2str2(dfs.getPlayerMoney()));
      else
        return new AnalystResult(UIReaction.UIR_ACTION_FOLD , "");
   
    if (combination.getCombinationValue() >=2)
      return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(dfs.getPlayerMoney()));
    else{
      if (combination.getCombinationValue() == 1){
        if (combination instanceof Pair){
          Pair pair = (Pair)combination;
          if (pair.isFromHeroCard || pair.isPoketPair){
            if (pair.pairType == TYPE.HIGH)
              return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(dfs.getPlayerMoney()));
            else {
              if (pair.pairType == TYPE.TOP ){
                  // TODO  handle kicker
                if (pair.isPoketPair)
                  return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(dfs.getPlayerMoney()));
               
                Card[] heroCards = board.getPlayingCards().getPlayerCards();
                  for (int i = 0; i< heroCards.length; i++){
                    if (heroCards[i].getFace() != pair.pairFace)
                      tmpcard = heroCards[i];
                  }                 
                 
                  if(tmpcard == null)
                    System.err.println("����� �� ����� ���� �������");
                  else
                  {
                    if (tmpcard.getFace().getSerialNumber() >= CardFace.JACK.getSerialNumber() )
                      return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(dfs.getPlayerMoney()));
                  }
              }
            }
          }
        }
       
      }
      return new AnalystResult(UIReaction.UIR_ACTION_FOLD , StringEx.float2str2(dfs.getPlayerMoney()));
    }*/
  }

  @Override
  public void initHandSets() {
    //Map<Hand,List<Integer>> handSets;
   
    List<Hand> setlist;
    List<Hand> tmplist;
   
    // 1 set JJ-AA, AK
    setlist = Hand.geterateHandFTS(CardFace.KING, CardFace.ACE, 0, true, true, false);
    setlist.addAll(Hand.geterateHandFTS(CardFace.JACK, CardFace.ACE, 0, true, true, true));   
    handSets.put(1, setlist);
   
    // 2 set 99-AA, AK, AQ
    setlist = Hand.geterateHandFTS(CardFace.QUEEN, CardFace.ACE, 0, true, true, false);
    setlist.addAll(Hand.geterateHandFTS(CardFace.NINE, CardFace.ACE, 0, true, true, true));   
    handSets.put(2, setlist);
   
    // 3 set 77-AA, AT, AJ, AQ, AK, KQ
    setlist = Hand.geterateHandFTS(CardFace.QUEEN, CardFace.ACE, 0, true, true, false);
    setlist.addAll(Hand.geterateHandFTS(CardFace.SEVEN, CardFace.ACE, 0, true, true, true));   
    setlist.addAll(Hand.geterateHandFTS(CardFace.QUEEN, CardFace.ACE, 0, true, true, false));
    setlist.addAll(Hand.geterateHandFTS(CardFace.JACK, CardFace.QUEEN, 0, true, false, false));
    setlist.addAll(Hand.geterateHandFTSOveral(CardFace.TEN, CardFace.ACE, 3, true, true, false, false, true));   
    handSets.put(3, setlist);
   
    // 4 - free
   
    // 5 set KK, AA
    setlist = Hand.geterateHandFTS(CardFace.KING, CardFace.ACE, 0, true, true, true);   
    handSets.put(5, setlist);
       
    // 6 set 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(6, setlist);
   

    // 7 set 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));
    setlist.addAll(Hand.geterateHandFTSOveral(CardFace.QUEEN, CardFace.KING, 0, true, false, false, false, false));
    //setlist.addAll(Hand.geterateHandFTS(CardFace.JACK, CardFace.ACE, 0, true, true, false));
    handSets.put(7, setlist);
   
    // 8 set 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));
    setlist.addAll(Hand.geterateHandFTSOveral(CardFace.QUEEN, CardFace.KING, 0, true, false, false, false, false));
    //setlist.addAll(Hand.geterateHandFTS(CardFace.JACK, CardFace.ACE, 0, true, true, false));
    handSets.put(8, setlist);
   
    // 9 set 77 - AA AT - AK, KQs
    setlist = Hand.geterateHandFTS(CardFace.SEVEN, CardFace.ACE, 0, true, true, true);
    //setlist.addAll(Hand.geterateHandFTS(CardFace.TEN, CardFace.ACE, 0, true, true, false));
    setlist.addAll(Hand.geterateHandFTSOveral(CardFace.JACK, CardFace.ACE, 0, true, true, false, false, true));
   
    setlist.addAll(Hand.geterateHandFTSOveral(CardFace.QUEEN, CardFace.KING, 0, true, false, false, false, false));
   
   
    handSets.put(9, setlist);
   
    // 10 set 66 - AA A9 - AK, KQs KJs QJs
    setlist = Hand.geterateHandFTS(CardFace.SEVEN, CardFace.ACE, 0, true, true, true);
    //setlist.addAll(Hand.geterateHandFTS(CardFace.NINE, CardFace.ACE, 0, true, true, false));
    setlist.addAll(Hand.geterateHandFTSOveral(CardFace.JACK, CardFace.ACE, 0, true, true, false, false, true));
   
    setlist.addAll(Hand.geterateHandFTSOveral(CardFace.JACK, CardFace.KING, 0, true, false, false, false, false));
    setlist.addAll(Hand.geterateHandFTSOveral(CardFace.QUEEN, CardFace.KING, 0, false, true, false, false, false));
   
   
    handSets.put(10, setlist);
   
    // 11 set 55 - AA A7 - AK
    setlist = Hand.geterateHandFTS(CardFace.SIX, CardFace.ACE, 0, true, true, true);
    //setlist.addAll(Hand.geterateHandFTS(CardFace.SEVEN, CardFace.ACE, 0, true, true, false));
    setlist.addAll(Hand.geterateHandFTSOveral(CardFace.SEVEN, CardFace.ACE, 0, true, true, false, false, true));
   
    setlist.addAll(Hand.geterateHandFTSOveral(CardFace.TEN, CardFace.KING, 0, true, true, false, false, false));
    //setlist.addAll(Hand.geterateHandFTSOveral(CardFace.QUEEN, CardFace.KING, 0, false, true, false, false, false));
   
    handSets.put(11, setlist);
   
  }

 
}

TOP

Related Classes of com.poker.analyst.strategy.temp.SSSStrategy1

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.