use of nars.rl.horde.functions.TabularAction in project narchy by automenta.
the class RLParkQLTest method main.
public static void main(String[] args) {
Integer[] actions = new Integer[] { 0, 1 };
int features = 2;
TabularAction ta = new TabularAction(actions, 1, features);
final double alpha = .1;
final double gamma = .99;
final double lambda = .3;
GQ gq = new GQ(alpha, 0.0, 1 - gamma, lambda, features);
QLearningControl.Greedy acting = new QLearningControl.Greedy(gq, actions, ta);
QLearningControl<Integer> q = new QLearningControl(acting, new QLearningControl.QLearning(actions, alpha, gamma, lambda, ta, gq.traces()));
ArrayRealVector xt = null;
int nextA = 0;
for (int i = 0; i < 1000; i++) {
double x1 = Math.random();
double x2 = Math.random();
System.out.println(Texts.n4(r) + " " + nextA);
System.out.println(Arrays.toString(gq.traces().vect().toArray()));
nextA = q.step(xt, nextA, xt = new ArrayRealVector(new double[] { x1, x2 }), r);
r = Math.abs(nextA - x2) - 0.5;
}
}
Aggregations