Package org.cspoker.ai.bots.bot.gametree.action

Examples of org.cspoker.ai.bots.bot.gametree.action.ProbabilityAction


    });
    // Multiset<ProbabilityAction> samples = new
    // HashMultiset<ProbabilityAction>();
    int nbSamples = Math.min(Max_Granularity, tokens);
    for (int i = 0; i < nbSamples; i++) {
      ProbabilityAction sampledAction = sampleAction(probActions,
          cumulProb);
      samples.add(sampledAction);
    }

    Set<Entry<ProbabilityAction>> entrySet = samples.entrySet();
View Full Code Here


      ImmutableList.Builder<INode> childrenBuilder = ImmutableList.builder();
      probabilities = new double[actions.size()];
      cumulativeProbability = new double[actions.size()];
      double cumul = 0;
      for (int i=0;i<actions.size();i++) {
        ProbabilityAction action = actions.get(i);
        double probability = action.getProbability();
        childrenBuilder.add(getChildAfter(action));
        cumul += probability;
        cumulativeProbability[i] = cumul;
        probabilities[i] = probability;
      }
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();
    final double average = node.getEV();
    String stddev;
    try {
      stddev = ""+Util.parseDollars(node.getStdDev());
    } catch (UnsupportedOperationException e) {
      stddev = "?";
    }
    final String stddevf = stddev;
    String nbSamplesInMean;
    try {
      nbSamplesInMean = node.getNbSamplesInMean()+"";
    } catch (UnsupportedOperationException e) {
      nbSamplesInMean = "?";
    }
    final String nbSamplesInMeanf = nbSamplesInMean;
    final double evStadDev = node.getEVStdDev();
    display.syncExec(new Runnable(){
      @Override
      public void run() {
        TreeItem newItem = previous==null? new TreeItem(tree, SWT.NONE):new TreeItem(previous, SWT.NONE);
        holder.item = newItem;
        newItem.setText(new String[] { actor,
            action.getAction().toString(),
            round.getName(),
            Math.round(100 * action.getProbability()) + "%",
            ""+nbSamples,
            ""+Util.parseDollars(average - relStackSize),
            stddevf,
            nbSamplesInMeanf,
            ""+Util.parseDollars(evStadDev),
View Full Code Here

          }
          newItem = new TreeItem(tree, SWT.NONE);
        } else {
          newItem = new TreeItem(item, SWT.NONE);
        }
        ProbabilityAction probAction;
        String samples = "?";
        if (action instanceof ProbabilityAction) {
          probAction = (ProbabilityAction) action;
        } else {
          throw new IllegalStateException("What action is this? "
              + action);
        }
        GameTreeNode node = pair.getRight();
        Round round = rounds.peek();
        rounds.push(node.getGameState().getRound());
        String actor = action.getAction().actor.equals(botId)?"Bot":"Player "+action.getAction().actor;
        newItem.setText(new String[] { actor,
            action.getAction().toString(), round.getName(),
            Math.round(100 * probAction.getProbability()) + "%",
            samples, "?", "?", "" + node.getNbTokens() ,
            ""+Util.parseDollars(node.getUpperWinBound() - relStackSize),
            ""+Util.parseDollars(node.getGameState().getGamePotSize()),
            ""+Util.parseDollars(lowerBound - relStackSize)
        });
View Full Code Here

        model.getFoldCallRaiseProbabilities(gameState, actor);
      model.forgetLastAssumption();
//      if (size != model.getVisitorSize()) throw new IllegalStateException("Model didn't forget last assumption");

      double foldProbability = probabilities.getLeft();
      actions.add(new ProbabilityAction(new FoldAction(gameState, actor), foldProbability));

      double callProbability = probabilities.getMiddle();
      actions.add(new ProbabilityAction(new CallAction(gameState, actor), callProbability));

      if (!gameState.getPlayer(bot).isAllIn()
          && gameState.isAllowedToRaise(actor)) {
        double raiseProbability = probabilities.getRight();
        addRaiseProbalities(gameState, actor, actions, raiseProbability,
            true, relBetSizeSamples, relPBetSizeSamples);     
      }
    } else {
      // check or bet
//      size = model.getVisitorSize();
      model.assumeTemporarily(gameState);
      Pair<Double, Double> probabilities = model.getCheckBetProbabilities(gameState, actor);
      model.forgetLastAssumption();
//      if (size != model.getVisitorSize()) throw new IllegalStateException("Model didn't forget last assumption");
     
      double checkProbability = probabilities.getLeft();
      actions.add(new ProbabilityAction(new CheckAction(gameState, actor), checkProbability));

      if (!gameState.getPlayer(bot).isAllIn()
          && gameState.isAllowedToRaise(actor)) {
        double betProbability = probabilities.getRight();
        addRaiseProbalities(gameState, actor, actions, betProbability,
            false, relBetSizeSamples, relPBetSizeSamples);
      }
    }
    ImmutableList.Builder<ProbabilityAction> normalizedActionsBuilder = ImmutableList.builder();
    for (ProbabilityAction action : actions) {
      normalizedActionsBuilder.add(new ProbabilityAction(action
          .getActionWrapper(), action.getProbability()));
   
    return normalizedActionsBuilder.build();
  }
View Full Code Here

      // call, raise or fold
      Triple<Double, Double, Double> probabilities =
        model.getFoldCallRaiseProbabilities(gameState, actor);

      double foldProbability = probabilities.getLeft();
      actions.add(new ProbabilityAction(new FoldAction(gameState, actor), foldProbability));

      double callProbability = probabilities.getMiddle();
      actions.add(new ProbabilityAction(new CallAction(gameState, actor), callProbability));

      if (!gameState.getPlayer(bot).isAllIn()
          && gameState.isAllowedToRaise(actor)) {
        double raiseProbability = probabilities.getRight();
        addRaiseProbalities(gameState, actor, actions, raiseProbability,
            true, getRelBetSizeSamples(), getRelPBetSizeSamples());     
      }
    } else {
      // check or bet
      Pair<Double, Double> probabilities = model.getCheckBetProbabilities(gameState, actor);
     
      double checkProbability = probabilities.getLeft();
      actions.add(new ProbabilityAction(new CheckAction(gameState, actor), checkProbability));

      if (!gameState.getPlayer(bot).isAllIn()
          && gameState.isAllowedToRaise(actor)) {
        double betProbability = probabilities.getRight();
        addRaiseProbalities(gameState, actor, actions, betProbability,
            false, getRelBetSizeSamples(), getRelPBetSizeSamples());
      }
    }
    ImmutableList.Builder<ProbabilityAction> normalizedActionsBuilder = ImmutableList.builder();
    for (ProbabilityAction action : actions) {
      normalizedActionsBuilder.add(new ProbabilityAction(action
          .getActionWrapper(), action.getProbability()));
   
    return normalizedActionsBuilder.build();
  }
View Full Code Here

          if (amountInt < lowerRaiseBound)
            amountInt += smallBlind;
          if (amountInt > upperRaiseBound)
            amountInt = upperRaiseBound;
          if (raise){
            actions.add(new ProbabilityAction(new RaiseAction(gameState,
                actor, amountInt), tmpProbability));
          } else
            actions.add(new ProbabilityAction(new BetAction(gameState,
                actor, amountInt), tmpProbability));
          tmpProbability = 0.0;
        }
       
      }
    } else {
      if (raise)
        actions.add(new ProbabilityAction(new RaiseAction(gameState,
            actor, lowerRaiseBound), raiseProbability));
      else
        actions.add(new ProbabilityAction(new BetAction(gameState,
            actor, lowerRaiseBound), raiseProbability));
    }
  }
View Full Code Here

TOP

Related Classes of org.cspoker.ai.bots.bot.gametree.action.ProbabilityAction

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.