List of usage examples for org.apache.commons.math3.random MersenneTwister nextInt
public int nextInt()
From source file:edu.oregonstate.eecs.mcplan.search.SparseSampleTree.java
/** * Computes the backed-up reward during the rollout stage. This is * usually a discounted value, possibly undiscounted. * @param r// w w w . j a va 2s. c o m * @return */ // public abstract double[] backupRollout( final double[] r ); // private Map<A, Double> makeQTable( final StateNode<X, A> root ) // { // final Map<A, Double> q = new HashMap<A, Double>(); // for( final ActionNode<X, A> an : Fn.in( root.successors() ) ) { // // TODO: This is where representing rollouts as ActionNodes with // // a = null is problematic. We could adopt the convention that // // ActionNodes with a = null are never counted, but then we need // // null tests everywhere. // if( an.a() != null ) { // q.put( an.a().create(), an.q( root.turn ) ); // } // } // return q; // } public static void main(final String[] args) { final MersenneTwister rng = new MersenneTwister(42); final Simulator sim = new Simulator(); final int width = 40; final int depth = 1; final Policy<State, UndoableAction<State>> rollout_policy = new RandomPolicy<State, UndoableAction<State>>( 0, rng.nextInt(), new ActionGen(rng)); final int rollout_depth = -1; final int rollout_width = 10; final SparseSampleTree<State, Representation<State>, UndoableAction<State>> tree = new SparseSampleTree<State, Representation<State>, UndoableAction<State>>( sim, new IdentityRepresenter(), new ActionGen(rng), width, depth, rollout_policy, rollout_width, rollout_depth, TimeLimitMctsVisitor.create(new Visitor<UndoableAction<State>>(), new Countdown(1000))) { @Override protected MutableStateNode<State, Representation<State>, UndoableAction<State>> createStateNode( final MutableActionNode<State, Representation<State>, UndoableAction<State>> an, final Representation<State> x, final int nagents, final int turn) { return new MaxStateNode<State, Representation<State>, UndoableAction<State>>(0, x, nagents, turn); } @Override protected MutableStateNode<State, Representation<State>, UndoableAction<State>> fetchStateNode( final MutableActionNode<State, Representation<State>, UndoableAction<State>> an, final Representation<State> x, final int nagents, final int turn) { // TODO Auto-generated method stub return null; } }; tree.run(); tree.root().accept(new TreePrinter<Representation<State>, UndoableAction<State>>()); }