示例#1
0
  private void streetAction(PerformedAction performedAction) {
    myBets += myBetsThisStreet;
    myBetsThisStreet = 0;
    theirBets += theirBetsThisStreet;
    theirBetsThisStreet = 0;

    changeEquity += changeEquityCall;

    changeEquityCall = 0.0;
    changeEquityTemp = 0.0;

    if (performedAction.getStreet().equalsIgnoreCase("FLOP")) {
      currentState = GameState.PRETURN;

      // changeEquity += (maj.getSDWRate() - 0.6) * sdwFactor / 2.0;
    } else if (performedAction.getStreet().equalsIgnoreCase("TURN")) {
      currentState = GameState.PRERIVER;

      changeEquity += (maj.getSDWRate() - 0.6) * sdwFactor / 4.0;
    } else if (performedAction.getStreet().equalsIgnoreCase("RIVER")) {
      currentState = GameState.POSTRIVER;

      changeEquity += (maj.getSDWRate() - 0.6) * sdwFactor / 4.0;
    }
  }
示例#2
0
  private void theirBetAction(PerformedAction performedAction) {
    theirBetsThisStreet += performedAction.getAmount();

    double potBet =
        (double) performedAction.getAmount() / (brain.potSize - performedAction.getAmount());

    if (potBet < 0.2) return;

    theirRaiseHistory[currentState.ordinal()].add(performedAction.getAmount());

    double PFR = adjustPFR(maj.getPFR());
    double AGGRO = adjustAggro(maj.getAggression());
    double AGGROFREQ = adjustAggroFreq(maj.getAggressionFrequency());

    double logFactor =
        HelperUtils.logisticSmall(3.0, 3.0, potBet)
            * Math.min(
                100.0,
                (HelperUtils.logistic(400.0, 400.0, performedAction.getAmount()) + 300.0) / 4);

    if (currentState == GameState.PREFLOP) {
      changeEquity -= pfRaiseFactor * logFactor / PFR;
    } else {
      changeEquity -= pfRaiseFactor * logFactor / AGGROFREQ;
    }

    changeEquityCall = 0.0;
  }
示例#3
0
  private void theirCheckAction(PerformedAction performedAction) {
    checkHistory[currentState.ordinal()] = true;

    double PFR = adjustPFR(maj.getPFR());
    double AGGRO = adjustAggro(maj.getAggression());
    double AGGROFREQ = adjustAggroFreq(maj.getAggressionFrequency());
    double CHECKRAISE = maj.getCheckRaise();

    if (currentState == GameState.PREFLOP) {
      changeEquityCall = pfCheckFactor * PFR * (1.0 - 4 * CHECKRAISE);
    } else {
      changeEquityCall = pfCheckFactor * AGGROFREQ * (1.0 - 4 * CHECKRAISE);
    }
  }
示例#4
0
  private void theirRaiseAction(PerformedAction performedAction) {

    double potBet =
        (double) (performedAction.getAmount() - theirBetsThisStreet)
            / (brain.potSize - performedAction.getAmount());
    if (potBet < 0.2) {
      theirBetsThisStreet += performedAction.getAmount();
      return;
    }

    theirRaiseHistory[currentState.ordinal()].add(performedAction.getAmount());

    double PFR = adjustPFR(maj.getPFR());
    double AGGRO = adjustAggro(maj.getAggression());
    double AGGROFREQ = adjustAggroFreq(maj.getAggressionFrequency());

    double logFactor =
        HelperUtils.logisticSmall(3.0, 3.0, potBet)
            * Math.min(
                100.0,
                (HelperUtils.logistic(
                            400.0, 400.0, performedAction.getAmount() - theirBetsThisStreet)
                        + 300.0)
                    / 4);

    double THREEB = maj.get3BetRate();
    double TWOB = maj.get2BetRate();

    if (myRaiseHistory[currentState.ordinal()].size() == 1
        && theirRaiseHistory[currentState.ordinal()].size() == 1) {
      logFactor *=
          1.0
              + (0.2 - TWOB)
                  * Math.min(100.0, myRaiseHistory[currentState.ordinal()].get(0))
                  / 30.0;
    } else if (theirRaiseHistory[currentState.ordinal()].size() == 2) {
      logFactor *= 1.0 + (0.25 - THREEB) * 1.5;
    } else if (theirRaiseHistory[currentState.ordinal()].size() >= 3) {
      logFactor *= 1.0 + (0.25 - THREEB) * 3.0;
    }

    if (currentState == GameState.PREFLOP) {
      changeEquity -= pfRaiseFactor * logFactor / PFR;
    } else {
      changeEquity -= pfRaiseFactor * logFactor / AGGROFREQ;
    }

    changeEquityCall = 0.0;
    theirBetsThisStreet += performedAction.getAmount();
  }
示例#5
0
  private void theirCallAction(PerformedAction performedAction) {
    // if(currentState == GameState.PREFLOP) {
    double PFR = adjustPFR(maj.getPFR());
    double CALLRAISE = maj.getCallRaise();

    //		if(currentState == GameState.PREFLOP) {
    //			changeEquityTemp -= callRaiseFactor * CALLRAISE;
    //		}

    // changeEquityCall = pfCallFactor * adjustedPFR / (1.0 +
    // theirRaiseHistory[currentState.ordinal()].size() +
    // myRaiseHistory[currentState.ordinal()].size());
    // equity += d * pfr / (1 + total number of raises (both players))
    // }

    theirBetsThisStreet = myBetsThisStreet;
  }
示例#6
0
  public void processInput(String input) {
    String[] tokens = input.split(" ");
    String word = tokens[0];
    if ("NEWGAME".compareToIgnoreCase(word) == 0) {
      String myName = tokens[1];
      String oppName = tokens[2];
      int stackSize = Integer.parseInt(tokens[3]);
      int bb = Integer.parseInt(tokens[4]);
      numHands = Integer.parseInt(tokens[5]);

      maj = new Historian(myName, oppName, stackSize, bb);
      // newGame();
    } else if ("KEYVALUE".compareToIgnoreCase(word) == 0) {
      if (tokens.length < 2) return;
      String[] smallTokens = tokens[1].split(":");
      if (smallTokens.length < 2) return;
      maj.notifyValue(smallTokens[0], smallTokens[1], tokens[2]); // the key value pair
    } else if ("NEWHAND".compareToIgnoreCase(word) == 0) {
      int handNum = Integer.parseInt(tokens[1]);

      if (handNum == numHands / 4) cons = true;
      if (handNum == numHands * 2 / 4) {
        System.out.println("Reg earnings: " + regEarnings + " consEarnings: " + consEarnings);
        if (consEarnings > regEarnings) cons = true;
        else cons = false;
      }

      System.out.println("Using conservative brain? " + cons);

      Card[] hand = new Card[3];
      hand[0] = CardUtils.getCardByString(tokens[3]);
      hand[1] = CardUtils.getCardByString(tokens[4]);
      hand[2] = CardUtils.getCardByString(tokens[5]);

      double timebank = Double.parseDouble(tokens[8]);

      Random rand = new Random();

      boolean callRaise = false, checkRaise = false;

      if (rand.nextDouble() < 0.5) {
        callRaise = true;
      }
      if (rand.nextDouble() < 0.5) {
        checkRaise = true;
      }

      if (cons) brain = new ConservativeBrain(maj, hand, timebank, callRaise, checkRaise);
      else brain = new Brain(maj, hand, timebank, callRaise, checkRaise);

      brain.handId = Integer.parseInt(tokens[1]);
      brain.button = Boolean.parseBoolean(tokens[2]);

      brain.board = new Card[5];

      brain.myBank = Integer.parseInt(tokens[6]);
      brain.oppBank = Integer.parseInt(tokens[7]);

      // newHand();
    } else if ("GETACTION".compareToIgnoreCase(word) == 0) {
      brain.potSize = Integer.parseInt(tokens[1]);

      brain.numBoardCards = Integer.parseInt(tokens[2]);
      int i = 3;
      for (; i < brain.numBoardCards + 3; i++)
        brain.board[i - 3] = CardUtils.getCardByString(tokens[i]);

      brain.numLastActions = Integer.parseInt(tokens[i]);
      brain.lastActions = new PerformedAction[brain.numLastActions];
      int j = i + 1;
      for (; j < brain.numLastActions + i + 1; j++) {
        brain.lastActions[j - i - 1] = ActionUtils.getPerformedActionByString(tokens[j]);
      }

      brain.numLegalActions = Integer.parseInt(tokens[j]);
      brain.legalActions = new LegalAction[brain.numLegalActions];

      int k = j + 1;
      for (; k < brain.numLegalActions + j + 1; k++)
        brain.legalActions[k - j - 1] = ActionUtils.getLegalActionByString(tokens[k]);

      brain.timebank = Double.parseDouble(tokens[k]);

      // String res = ActionUtils.performedActionToString((PerformedAction)brain.act());
      // System.out.println(res);
      outStream.println(ActionUtils.performedActionToString((PerformedAction) brain.act()));
    } else if ("HANDOVER".compareToIgnoreCase(word) == 0) {
      brain.myBank = Integer.parseInt(tokens[1]);
      brain.oppBank = Integer.parseInt(tokens[2]);

      if (cons) {
        consEarnings = brain.myBank - regEarnings;
      } else {
        regEarnings = brain.myBank;
      }

      brain.numBoardCards = Integer.parseInt(tokens[3]);
      int i = 4;
      for (; i < brain.numBoardCards + 4; i++)
        brain.board[i - 4] = CardUtils.getCardByString(tokens[i]);

      brain.numLastActions = Integer.parseInt(tokens[i]);
      brain.lastActions = new PerformedAction[brain.numLastActions];
      int j = i + 1;
      for (; j < brain.numLastActions + i + 1; j++) {
        brain.lastActions[j - i - 1] = ActionUtils.getPerformedActionByString(tokens[j]);
      }

      maj.update(brain.lastActions);
      maj.numHandsPlayed++;

      System.out.println("\nPFR: " + maj.getPFR());
      System.out.println("SDW: " + maj.getSDWRate() + "\n");
    } else if ("REQUESTKEYVALUES".compareToIgnoreCase(word) == 0) {
      // At the end, engine will allow bot to send key/value pairs to store.
      // FINISH indicates no more to store.
      outStream.println("DELETE " + maj.oppName);
      outStream.println("PUT " + maj.oppName + ":PFR " + maj.getValueToSave("PFR"));
      outStream.println("PUT " + maj.oppName + ":SDW " + maj.getValueToSave("SDW"));
      outStream.println("FINISH");
    }
  }
示例#7
0
 private void theirPostAction(PerformedAction performedAction) {
   theirBetsThisStreet += performedAction.getAmount();
   changeEquity += (maj.getSDWRate() - 0.6) * sdwFactor;
 }