use of jcog.tree.rtree.rect.RectFloat2D in project narchy by automenta.
the class Ortho method unzoom.
@Override
public void unzoom() {
synchronized (zoomStack) {
if (!zoomStack.isEmpty()) {
RectFloat2D z = zoomStack.removeLast().get();
scale(z.w, z.h);
cam.set(z.cx(), z.cy());
}
}
}
use of jcog.tree.rtree.rect.RectFloat2D in project narchy by automenta.
the class TrackXY method main.
public static void main(String[] args) {
boolean nars = true;
boolean rl = false;
int dur = 1;
NARS nb = new NARS().exe(new UniExec(64)).time(new CycleTime().dur(dur)).index(// new HijackConceptIndex(4 * 1024, 4)
new CaffeineIndex(32 * 1024));
NAR n = nb.get();
n.termVolumeMax.set(20);
// n.priDefault(BELIEF, 0.2f);
// n.priDefault(GOAL, 0.5f);
n.activationRate.set(0.2f);
// n.forgetRate.set(0.9f);
TrackXY t = new TrackXY(4, 4);
n.on(t);
int experimentTime = 8048;
n.synch();
if (rl) {
new RLBooster(t, // HaiQ::new,
HaiQae::new, // RandomAgent::new,
1);
t.curiosity.set(0);
}
if (nars) {
// Param.DEBUG = true;
// n.log();
// for (String action : new String[]{"up", "down", "left", "right"}) {
// //n.goal($.the(action), Tense.Present, 0f, 0.1f);
// n.goal($.the(action), Tense.Present, 1f, 0.1f);
// }
Deriver d = new Deriver(Derivers.rules(// 1,
1, 8, n, // "list.nal",
"motivation.nal"), n);
d.conceptsPerIteration.set(32);
n.timeFocus.set(2);
ConjClustering cjB = new ConjClustering(n, BELIEF, // (tt)->true,
(tt) -> tt.isInput(), 4, 16);
// ConjClustering cjG = new ConjClustering(n, GOAL,
// (tt)->true,
// //(tt) -> tt.isInput(),
// 5, 16);
// Implier ii = new Implier(t , 0, 1);
// ArithmeticIntroduction ai = new ArithmeticIntroduction(4, n);
window(new Gridding(new AutoSurface(d), new AutoSurface(cjB)), 400, 300);
n.onTask(tt -> {
if (tt instanceof DerivedTask && tt.isGoal()) {
System.out.println(tt.proof());
}
});
}
// n.log();
// n.startFPS(fps);
// t.runFPS(fps);
n.onCycle(t);
final double[] rewardSum = { 0 };
n.onCycle(() -> {
rewardSum[0] += t.reward;
});
n.runLater(() -> {
window(Vis.top(n), 800, 250);
NAgentX.chart(t);
window(new CameraSensorView(t.cam, n) {
@Override
protected void paint(GL2 gl, int dtMS) {
super.paint(gl, dtMS);
RectFloat2D at = cellRect(t.sx, t.sy, 0.5f, 0.5f);
gl.glColor4f(1, 0, 0, 0.9f);
Draw.rect(gl, at.move(x(), y(), 0.01f));
}
}.withControls(), 800, 800);
});
n.run(experimentTime);
// n.startFPS(10f);
// t.runFPS(10f);
// System.out.println(
//
// n4(rewardSum[0] / n.time()) + " avg reward");
// System.exit(0);
}
use of jcog.tree.rtree.rect.RectFloat2D in project narchy by automenta.
the class Ortho method zoom.
@Override
public void zoom(Surface su) {
synchronized (zoomStack) {
// /if (!zoomStack.isEmpty()) {
// if (!zoomStack.getLast().contains(nextZoom)) {
// zoomStack.clear();
/* } else */
RectFloat2D target;
// if (!zoomStack.isEmpty() && zoomStack.getLast().gfinger.touching==su) { //zoomStack.size()>1 && zoomStack.getLast().get().equals(su.bounds /* TODO maybe fuzzy equals */)) {
// zoomStack.removeLast();
// target = zoomStack.getLast().get();
// } else {
{
if (zoomStack.size() > ZOOM_STACK_MAX) {
zoomStack.removeFirst();
}
// }
float s = scale.x;
RectFloat2D curZoom = new RectFloat2D(cam.x - s / 2, cam.y - s / 2, cam.x + s / 2, cam.y + s / 2);
zoomStack.addLast(() -> curZoom);
target = su.bounds;
}
zoom(target);
}
}
use of jcog.tree.rtree.rect.RectFloat2D in project narchy by automenta.
the class Finger method relative.
public static v2 relative(v2 x, Surface c) {
v2 y = new v2(x);
RectFloat2D b = c.bounds;
y.sub(b.x, b.y);
y.scaled(1f / b.w, 1f / b.h);
return y;
}
use of jcog.tree.rtree.rect.RectFloat2D in project narchy by automenta.
the class SubOrtho method posWindow.
// public void maximize() {
//
// posWindow(0, 0, 1, 1);
// }
/**
* position and size relative to the containing window (1=width, 1=height)
*/
public Ortho posWindow(float x, float y, float w, float h) {
this.boundsWin = new RectFloat2D(x, y, w, h);
layout();
return this;
}
Aggregations