Package org.cspoker.ai.bots.bot.gametree.mcts.nodes

Examples of org.cspoker.ai.bots.bot.gametree.mcts.nodes.InnerNode


    HashMap<Class<?>, Double> probs = new HashMap<Class<?>, Double>();
    Class<?> cProb = null;
    RaiseAction raiseAction = null;
    BetAction betAction = null;
    String errorStr = "";
    InnerNode node = getNode(gameState);
    if (node != null) {
      errorStr = (">-----------------------------");
      errorStr += ("\n" + getPlayerName(gameState) + " State " + gameState.getClass());
      ImmutableList<INode> children = node.getChildren();
      if (children != null) {
        for (INode n : children) {
          Class<?> c = n.getLastAction().getAction().getClass();
          // Same actions are grouped to make one probability (bet/raise)
          if (!probs.containsKey(c))
            probs.put(c, n.getLastAction().getProbability());
          else
            probs.put(c, n.getLastAction().getProbability() + probs.get(c));
          actions.put(c, n.getLastAction().getAction());
         
          if (gameState.getClass().equals(
              n.getLastAction().getAction()
                  .getUnwrappedStateAfterAction().getClass()) ||
            // TODO: you shouldn't get BetAction in RaiseState (but it does happen somehow...)
            (gameState.getClass().equals(RaiseState.class) &&
                n.getLastAction().getAction().getClass().equals(BetAction.class))) {// ||
//            // TODO: idem with Raise-/BetAction in AllinState (now this situation is ignored)
//            (gameState.getClass().equals(AllInState.class) &&
//                n.getLastAction().getAction().getClass().equals(BetAction.class))) {
            if (cProb == null) {
              errorStr += "\n Setting chosen node with action " + n.getLastAction().getAction();
              parentOpponentModel.setChosenNode(n);
            }
            cProb = c;
            if (raiseAction == null && c.equals(RaiseAction.class))
              raiseAction = (RaiseAction) n.getLastAction().getAction();
            else if (betAction == null && c.equals(BetAction.class))
              betAction = (BetAction) n.getLastAction().getAction();
          }
         
          // Correct child node is chosen for bet/raise
          if (cProb != null) {
            if (raiseAction != null && c.equals(RaiseAction.class)) {
              RaiseAction newRaiseAction = (RaiseAction) n.getLastAction().getAction();
              if (Math.abs(newRaiseAction.amount - raiseAmount) <
                  Math.abs(raiseAction.amount - raiseAmount)) {
                raiseAction = newRaiseAction;
                errorStr += "\n Setting chosen node with action " + n.getLastAction().getAction();
                parentOpponentModel.setChosenNode(n);
              }
            }
            else if (betAction != null && c.equals(BetAction.class)) {
              BetAction newBetAction = (BetAction) n.getLastAction().getAction();
              if (Math.abs(newBetAction.amount - raiseAmount) <
                  Math.abs(betAction.amount - raiseAmount)) {
                betAction = newBetAction;
                errorStr += "\n Setting chosen node with action " + n.getLastAction().getAction();
                parentOpponentModel.setChosenNode(n);
              }
            }
          }
          errorStr += ("\nState "
              + n.getLastAction().getAction().getUnwrappedStateAfterAction().getClass()
              + " with action "
              + n.getLastAction().getAction()
              + "\t with probability "
              + (double) Math.round(n.getLastAction().getProbability() * 10000) / 100
              + "% and totalProb "
              + (double) Math.round(probs.get(c) * 10000) / 100 + "%");
        }
        errorStr += ("\n> Chosen child with action " +
            parentOpponentModel.getChosenNode().getLastAction().getAction());
      } else {
        errorStr += ("\nNo children for node with action " +
          node.getLastAction().getAction());
      }
      errorStr += ("\n-----------------------------<");
    }
   
    // chosen node of opponentmodel should have changed
View Full Code Here


          (data.trueNegative + data.truePositive + data.falseNegative + data.falsePositive);
  }
 
  @Override
  public void visitCallState(CallState callState) {
    InnerNode node = getNode(callState);
    if (node != null && !callState.getNextToAct().equals(parentOpponentModel.getBotId())) {
      Prediction p = getProbability(callState);
      assimilatePrediction(callState.getNextToAct(), p);
      getPropz().logCallProb(callState.getNextToAct(), p);
      logger.trace(getPlayerName(callState) + " " + p);
View Full Code Here

    propz.signalCall(false, callState.getEvent().getPlayerId());
  }
 
  @Override
  public void visitRaiseState(RaiseState raiseState) {
    InnerNode node = getNode(raiseState);
    if (node != null && !raiseState.getNextToAct().equals(parentOpponentModel.getBotId())) {
      Prediction p = getProbability(raiseState,raiseState.getLargestBet());
      assimilatePrediction(raiseState.getNextToAct(), p);
      getPropz().logRaiseProb(raiseState.getNextToAct(), p);
      logger.trace(getPlayerName(raiseState) +
View Full Code Here

    propz.signalRaise(false, raiseState.getLastEvent().getPlayerId(), raiseState.getLargestBet());
  }
 
  @Override
  public void visitFoldState(FoldState foldState) {
    InnerNode node = getNode(foldState);
    if (node != null && !foldState.getNextToAct().equals(parentOpponentModel.getBotId())) {
      Prediction p = getProbability(foldState);
      assimilatePrediction(foldState.getNextToAct(), p);
      getPropz().logFoldProb(foldState.getNextToAct(), p);
      logger.trace(getPlayerName(foldState) + " " + p);
View Full Code Here

    propz.signalFold(foldState.getEvent().getPlayerId());
  }
 
  @Override
  public void visitCheckState(CheckState checkState) {
    InnerNode node = getNode(checkState);
    if (node != null && !checkState.getNextToAct().equals(parentOpponentModel.getBotId())) {
      Prediction p = getProbability(checkState);
      assimilatePrediction(checkState.getNextToAct(), p);
      getPropz().logCheckProb(checkState.getNextToAct(), p);
      logger.trace(getPlayerName(checkState) + " " + p);
View Full Code Here

    propz.signalCheck(checkState.getEvent().getPlayerId());
  }
 
  @Override
  public void visitBetState(BetState betState) {
    InnerNode node = getNode(betState);
    if (node != null && !betState.getNextToAct().equals(parentOpponentModel.getBotId())) {
      Prediction p = getProbability(betState, betState.getEvent().getAmount());
      assimilatePrediction(betState.getNextToAct(), p);
      getPropz().logBetProb(betState.getNextToAct(), p);
      logger.trace(getPlayerName(betState) +
View Full Code Here

    propz.signalBet(false, betState.getEvent().getPlayerId(), betState.getEvent().getAmount());
  }
 
  @Override
  public void visitAllInState(AllInState allInState) {
    InnerNode node = getNode(allInState);
    if (node != null && !allInState.getNextToAct().equals(parentOpponentModel.getBotId())) {
      Prediction p = getProbability(allInState, allInState.getEvent().getMovedAmount());
      assimilatePrediction(allInState.getNextToAct(), p);
     
      if (p != null) {
View Full Code Here

      }
    });
  }

  private void visitNode(INode node, final TreeItem previous) {
    InnerNode parent = node.getParent();
    final Round round = parent==null?startRound:parent.gameState.getRound();
    final ProbabilityAction action = node.getLastAction();
    final String actor = action.getAction().actor.equals(botId)?"Bot":"Player "+action.getAction().actor;
    final TreeItemHolder holder = new TreeItemHolder();
    final int nbSamples = node.getNbSamples();
View Full Code Here

TOP

Related Classes of org.cspoker.ai.bots.bot.gametree.mcts.nodes.InnerNode

Copyright © 2018 www.massapicom. 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.