@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));
}
}