Package com.poker.analyst.strategy.temp

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

package com.poker.analyst.strategy.temp;

import java.util.List;

import com.poker.analyst.AnalystResult;
import com.poker.analyst.combination.Combination;
import com.poker.analyst.element.Board;
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.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 BSSStrategy extends Strategy {

 
  public BSSStrategy(String heroName) {

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

    @Override
  public boolean maySitToTable(DataForStrategy dfs) {
    // TODO Auto-generated method stub
    return false;
  }

  @Override
  public AnalystResult getPreFlopReaction(DataForStrategy dfs) {
    Board board = dfs.getCurrentBoard();
   
    float bb = board.getBigBlind();             
    boolean isFirstCircle = true;
   
    int limpersCount = -1;
    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();
    }
           
    if (board.getPlayers().get(board.getHero()).getName().trim() == "")
      isFirstCircle = true;
    else {
      isFirstCircle = false;     
    }

    for (Player player: board.getPlayers()){
      if (FloatEx.equals4(player.getBet() - bb,0f))
        limpersCount ++;
    }
   
    int tmp;         
     
    if (board.getNumOfRaises() != 0){
      if (board.getNumOfRaises() == 1){
        tmp = -1;
        for (Player pl: board.getPlayers())
          if (FloatEx.equals4(pl.getBet(), maxBet)){
            if (stackOfFirstRaiser < 0f) stackOfFirstRaiser = pl.getStack();
            tmp++; 
          }
        raiseAmount = FloatEx.cutFloat2(new Float(maxBet *(3 + tmp)));
        callers = tmp;                           
      }else{
        if (checkHandForHSet(heroHand,1))
          return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(board.getPlayers().get(board.getHero()).getStack()));         
      }         
    }
    else{
      raiseAmount = FloatEx.cutFloat2(new Float(bb *(4 + limpersCount) ) );
    }
   
    if (isFirstCircle){
      switch (board.getPosition()) {
        case EARLY_POSITION:                             
          // no raises
          if (board.getNumOfRaises() == 0){           
            if (checkHandForHSet(heroHand,11) ||
              checkHandForHSet(heroHand,12) ||
              checkHandForHSet(heroHand,21))         
              return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
          }else
          if (board.getNumOfRaises() == 1){
            // one raise
            if (callers == 0){
              if (checkHandForHSet(heroHand,11) ||              
                checkHandForHSet(heroHand,12))         
                return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));

              // call-20
              if ((checkHandForHSet(heroHand,12) || checkHandForHSet(heroHand,13)) &&
                (stackOfFirstRaiser > 20 * maxBet &&
                board.getPlayers().get(board.getHero()).getStack() > maxBet))
                return new AnalystResult(UIReaction.UIR_ACTION_CALL, "");                                                                 
             
            }else{
              if (checkHandForHSet(heroHand,11) ||
                checkHandForHSet(heroHand,12) ||
                checkHandForHSet(heroHand,21))         
                return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
            }
          }else{
            if (checkHandForHSet(heroHand,1))
              return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
          }
         
          return new AnalystResult(UIReaction.UIR_ACTION_FOLD, "");

                 
        case MIDDLE_POSITION: 
          // no raises
          if (board.getNumOfRaises() == 0){           
            if (checkHandForHSet(heroHand,11) ||
              checkHandForHSet(heroHand,22) ||
              checkHandForHSet(heroHand,21) ||
              checkHandForHSet(heroHand,12))         
              return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
          }else
          if (board.getNumOfRaises() == 1){
            // one raise
            if (callers ==0){
              if (checkHandForHSet(heroHand,11) ||               
                checkHandForHSet(heroHand,21))
                         
                return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
             
              // call-20
              if ((checkHandForHSet(heroHand,12) || checkHandForHSet(heroHand,13)) &&
                (stackOfFirstRaiser > 20 * maxBet &&
                board.getPlayers().get(board.getHero()).getStack() > maxBet))
                return new AnalystResult(UIReaction.UIR_ACTION_CALL, "");                                     
             
            }else{
              if (checkHandForHSet(heroHand,11) ||
                checkHandForHSet(heroHand,12) ||
                checkHandForHSet(heroHand,21))         
                return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
             
              if (checkHandForHSet(heroHand,13) ||
                checkHandForHSet(heroHand,31) ||
                checkHandForHSet(heroHand,33) )         
                return new AnalystResult(UIReaction.UIR_ACTION_CALL, "");
            }
          }else{
            if (checkHandForHSet(heroHand,1))
              return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
          }
         
          return new AnalystResult(UIReaction.UIR_ACTION_FOLD, "");
        case LAST_POSITION:  
          // no raises
          if (board.getNumOfRaises() == 0){           
            if (checkHandForHSet(heroHand,11) ||
              checkHandForHSet(heroHand,12) || 
              checkHandForHSet(heroHand,13) ||
              checkHandForHSet(heroHand,21) ||
              checkHandForHSet(heroHand,22) ||
              checkHandForHSet(heroHand,23) ||
              checkHandForHSet(heroHand,31) ||
              checkHandForHSet(heroHand,32) ||
              checkHandForHSet(heroHand,33))
              return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
          }else
          if (board.getNumOfRaises() == 1){
            // one raise
            if (callers ==0){             
              if (checkHandForHSet(heroHand,11) ||               
                checkHandForHSet(heroHand,21))                         
                return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
             
              // call-20
              if ((checkHandForHSet(heroHand,12) || checkHandForHSet(heroHand,13)) &&
                (stackOfFirstRaiser > 20 * maxBet &&
                board.getPlayers().get(board.getHero()).getStack() > maxBet))
                return new AnalystResult(UIReaction.UIR_ACTION_CALL, "");                                     
             
            }else{
              if (checkHandForHSet(heroHand,11) ||               
                checkHandForHSet(heroHand,12) ||
                checkHandForHSet(heroHand,21) ||               
                checkHandForHSet(heroHand,22) )                         
                return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
             
              if (checkHandForHSet(heroHand,13) ||
                checkHandForHSet(heroHand,23) ||
                checkHandForHSet(heroHand,31) ||
                checkHandForHSet(heroHand,33) )         
                return new AnalystResult(UIReaction.UIR_ACTION_CALL, "");
            }
          }else{
            if (checkHandForHSet(heroHand,1))
              return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
          }
         
          return new AnalystResult(UIReaction.UIR_ACTION_FOLD, "");
                   
        case BLINDS:      
          // no raises
          if (board.getNumOfRaises() == 0){           
            if (checkHandForHSet(heroHand,11) ||
              checkHandForHSet(heroHand,12) || 
              checkHandForHSet(heroHand,21) ||
              checkHandForHSet(heroHand,22) ||
              checkHandForHSet(heroHand,23) ||
              checkHandForHSet(heroHand,31) ||
              checkHandForHSet(heroHand,32))
              return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
          }else
          if (board.getNumOfRaises() == 1){
            // one raise
            if (callers ==0){             
              if (checkHandForHSet(heroHand,11) ||               
                checkHandForHSet(heroHand,21))                         
                return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
             
              // call-20
              if ((checkHandForHSet(heroHand,12) || checkHandForHSet(heroHand,13)) &&
                (stackOfFirstRaiser > 20 * maxBet &&
                board.getPlayers().get(board.getHero()).getStack() > maxBet))
                return new AnalystResult(UIReaction.UIR_ACTION_CALL, "");                                   
             
            }else{
              if (checkHandForHSet(heroHand,11) ||               
                checkHandForHSet(heroHand,12) ||
                checkHandForHSet(heroHand,21))                                       
                  return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
             
              if (checkHandForHSet(heroHand,13) ||
                checkHandForHSet(heroHand,22) ||
                checkHandForHSet(heroHand,23) ||
                checkHandForHSet(heroHand,31) ||
                checkHandForHSet(heroHand,32) ||
                checkHandForHSet(heroHand,33) )         
                return new AnalystResult(UIReaction.UIR_ACTION_CALL, "");
            }
          }else{
            if (checkHandForHSet(heroHand,1))
              return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
          }
         
          return new AnalystResult(UIReaction.UIR_ACTION_FOLD, "");
        default: System.err.println("�� ���������� �������");
          break;
      }  
    }else{
      if (checkHandForHSet(heroHand,1))
        return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(raiseAmount));
     
      if (board.needAmountToCall() < 1.1 * bb)
        return new AnalystResult(UIReaction.UIR_ACTION_CALL, "");     
     
      if (board.getPlayers().get(board.getHero()).getStack() < 2 * bb)
        return new AnalystResult(UIReaction.UIR_ACTION_RAISE, StringEx.float2str2(board.getPlayers().get(board.getHero()).getStack()));
     
      return new AnalystResult(UIReaction.UIR_ACTION_FOLD, "");
    }
   
    return null;
  }

  @Override
  public AnalystResult getFlopReaction(DataForStrategy dfs) {
    /*final CombinationMatcher matcher = new CombinationMatcher();              
        Combination combination = matcher.analyzeCombination(dfs.getCurrentBoard().getPlayingCards(), dfs.getCurrentRound());
        */
       
       
       
       
       
    return null;
  }

  @Override
  public AnalystResult getTurnReaction(DataForStrategy dfs) {
    // TODO Auto-generated method stub
    return null;
  }

  @Override
  public AnalystResult getRiverReaction(DataForStrategy dfs) {
    // TODO Auto-generated method stub
    return null;
  }

  @Override
  public AnalystResult isNeedRebuy(DataForStrategy dfs) {
    // TODO Auto-generated method stub
    return null;
  }

  @Override
  public ActionBeforePlay getPreparedAction(DataForStrategy dfs) {
    // TODO Auto-generated method stub
    return null;
  }

  @Override
  public void initHandSets() {
    List<Hand> setlist;
   
   
 
   
   
  //  PAIRS
    // 1 set
    // AA, KK
    setlist = Hand.geterateHandFTS(CardFace.KING, CardFace.ACE, 0, true, true, true);
    handSets.put(1, setlist);
 
     
     
     
    // 11 set
    // AA, KK, QQ
    setlist = Hand.geterateHandFTS(CardFace.QUEEN, CardFace.ACE, 0, true, true, true);
    handSets.put(11, setlist);
   
   
   
    // 12 set
    // JJ, TT
    setlist = Hand.geterateHandFTS(CardFace.TEN, CardFace.JACK, 0, true, true, true);
    handSets.put(12, setlist);
   
    // 13 set
    // 99 - 22    
    setlist = Hand.geterateHandFTS(CardFace.TWO, CardFace.NINE, 0, true, true, true);
    handSets.put(13, setlist);

  // ACES
    // 21 set
    // AK   
    setlist = Hand.geterateHandFTS(CardFace.KING, CardFace.ACE, 0, true, true, false);
    handSets.put(21, setlist);
   
    // 22 set
    // AQ, AJ, AT    
    setlist = Hand.geterateHandFTSOveral(CardFace.QUEEN, CardFace.ACE, 0, true, true, false, true, true);
    setlist.addAll(Hand.geterateHandFTSOveral(CardFace.JACK, CardFace.ACE, 0, true, true, false, true, true));
    setlist.addAll(Hand.geterateHandFTSOveral(CardFace.TEN, CardFace.ACE, 0, true, true, false, true, true));
    handSets.put(22, setlist);
   
    // 23 set
    // A9s - A2s    
    setlist = Hand.geterateHandFTSOveral(CardFace.TWO, CardFace.ACE, 5, true, false, false, false, true);       
    handSets.put(23, setlist);
   
  // OTHER
    // 31 set
    // KQs, KJs, KTs, QJs, QTs, JTs
    setlist = Hand.geterateHandFTSOveral(CardFace.TEN, CardFace.KING, 0, true, false, false, false, false);
    handSets.put(31, setlist);
   
    // 32 set
    // KQo, KJo, KTo, QJo, QTo, JTo    
    setlist = Hand.geterateHandFTSOveral(CardFace.TEN, CardFace.KING, 0, false, true, false, false, false);
    handSets.put(32, setlist);
   
    // 33 set
    // T9s - 54s    
    setlist = Hand.geterateHandFTS(CardFace.NINE, CardFace.TEN, 0, true, false, false);
    setlist.addAll(Hand.geterateHandFTS(CardFace.EIGHT, CardFace.NINE, 0, true, false, false));
    setlist.addAll(Hand.geterateHandFTS(CardFace.SEVEN, CardFace.EIGHT, 0, true, false, false));
    setlist.addAll(Hand.geterateHandFTS(CardFace.SIX, CardFace.SEVEN, 0, true, false, false));
    setlist.addAll(Hand.geterateHandFTS(CardFace.FIVE, CardFace.SIX, 0, true, false, false));
    setlist.addAll(Hand.geterateHandFTS(CardFace.FOUR, CardFace.FIVE, 0, true, false, false));
    handSets.put(33, setlist);
         
  }
}
TOP

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

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.