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