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

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


  @Override
  public void doNextAction() throws RemoteException, IllegalActionException {
    startTime = System.currentTimeMillis();
    long endTime = System.currentTimeMillis()+decisionTime;
    GameState gameState = tableContext.getGameState()
    RootNode root = new RootNode(gameState,botId,config);
    logger.info("Starting MCTS iterations.");
    do{
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
    }while(System.currentTimeMillis()<endTime);
    INode node = root.selectChild(config.getMoveSelectionStrategy());
    config.getModel().setChosenNode(node);
//    try {
//    ImmutableList<INode> children = ((InnerNode) node).getChildren();
//    for (INode n: children) {
//      String str = " <last action> ";
//      str = "" + n.getLastAction().getAction().getUnwrappedStateAfterAction().getClass();
//      System.out.println("Child " +  str
//          + " with action " + n.getLastAction().getAction() + " with probability " +
//          n.getLastAction().getProbability());
//    }
//    } catch (ClassCastException e) {
//      System.out.println("-------------\nNO CLASS CAST\n-------------"); // do nothing
//    }
    SearchBotAction action = node.getLastAction().getAction();
    if(logger.isInfoEnabled())
      logger.info("Stopped MCTS after "+root.getNbSamples()+" samples and choosing "+action);
   
    // to calculate efficiency of sampling algorithms
//    if (tableContext.getGameState().getRound() == Round.PREFLOP)
//      System.out.print(root.getNbSamples());
//    System.out.print("\t");
View Full Code Here


  @Override
  public void doNextAction() throws RemoteException, IllegalActionException {
//    long startTime = System.currentTimeMillis();
    GameState gameState = tableContext.getGameState()
    RootNode root = new RootNode(gameState,botId,config);
    switch (gameState.getRound()) {
    case PREFLOP: nbSamples = samplesPreFlop; break;
    case FLOP: nbSamples = samplesFlop; break;
    case TURN: nbSamples = samplesTurn; break;
    case FINAL: nbSamples = samplesRiver; break;
    default: throw new IllegalStateException(gameState.getRound().toString());
    }
    do{
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
      iterate(root);
    }while(root.getNbSamples()<nbSamples);   
   
    // to calculate efficiency of sampling algorithms
//    if (tableContext.getGameState().getRound() == Round.FINAL)
//      System.out.println(System.currentTimeMillis()-startTime);
   
    if(logger.isDebugEnabled()){
      logger.debug("Stopped MCTS.");
    }
    root.selectChild(config.getMoveSelectionStrategy()).getLastAction().getAction().perform(playerContext);
   
    MCTSListener[] listeners = createListeners(tableContext.getGameState(), botId);
    for (MCTSListener listener : listeners) {
      listener.onMCTS(root);
    }
View Full Code Here

TOP

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

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.