use of nars.NARS in project narchy by automenta.
the class WorkerMultiExecTest method testValueDerivationBranches.
@Test
public void testValueDerivationBranches() throws Narsese.NarseseException {
// int threads = 1;
// Exec exe = new MultiExec(32, threads, 2);
Exec exe = new UniExec(32);
NAR n = new NARS().deriverAdd(1, 1).deriverAdd(6, 6).exe(exe).get();
// all -1 except goal production
Arrays.fill(n.emotion.want, -1);
n.emotion.want(MetaGoal.Desire, +1);
Exec.Revaluator r = new Focus.DefaultRevaluator();
int cycles = 100;
// 2 competing independent processes. NAL1 rules will apply to one, and NAL6 rules apply to ther other.
// measure the amount of derivation work occurring for each
ByteIntHashMap byPunc = new ByteIntHashMap();
n.onTask(t -> {
if (t instanceof DerivedTask) {
byPunc.addToValue(t.punc(), 1);
}
});
n.log();
n.input("(x==>y).");
n.input("f:a.");
for (int i = 0; i < cycles; i++) {
n.input("f:b. :|:");
n.input("x! :|:");
n.run(1);
r.update(n);
}
System.out.println(byPunc);
n.causes.forEach(c -> {
double sum = Util.sum((ToDoubleFunction<Traffic>) (t -> t.total), c.goal);
if (sum > Double.MIN_NORMAL) {
System.out.println(Arrays.toString(c.goal) + "\t" + c);
}
});
}
use of nars.NARS in project narchy by automenta.
the class Line1DQ method main.
public static void main(String[] args) {
// Param.DEBUG = true;
NAR n = new NARS().get();
// n.log();
n.time.dur(5);
Line1DSimplest a = new Line1DSimplest();
a.curiosity.set(0.01f);
a.onFrame((z) -> {
a.target(Util.unitize(// (float) (0.5f * (Math.sin(n.time() / 50f) + 1f))
(Math.abs(3484 ^ n.time() / 200) % 11) / 10.0f));
});
// Arkancide a = new Arkancide(n, false, true);
// Tetris a = new Tetris(n, 6, 10, 4);
// a.onFrame(x -> Util.sleep(1));
// a.trace = true;
// Line1DTrainer trainer = new Line1DTrainer(a);
// new RLBooster(a, new HaiQAgent(), 2); n.deriver.rate.setValue(0); a.curiosity.setValue(0f);
NAgentX.chart(a);
// int h = q.ae.W[0].length;
// int w = q.ae.W.length;
// window( grid(
// new MatrixView(w, h, MatrixView.arrayRenderer(q.ae.W)),
// new MatrixView(w, 1, MatrixView.arrayRenderer(q.ae.y)),
// new MatrixView(w, 1, MatrixView.arrayRenderer(q.ae.z))
// ), 500, 500);
float grandTotal = 0;
for (int i = 0; i < 100; i++) {
int period = 1000;
// a.runCycles(period);
}
System.err.println(" grand total = " + grandTotal);
}
use of nars.NARS in project narchy by automenta.
the class RoverMaze1 method main.
public static void main(String[] args) {
Rover r = new Rover(new NARS().get()) {
@Override
protected void create(Dynamics3D world) {
SimpleSpatial torso;
add(torso = new SimpleSpatial("torso") {
@Override
protected CollisionShape newShape() {
// return new CylinderShape(v(1f, 0.1f, 1f));
return new BoxShape(v(1.6f, 0.1f, 1f));
}
@Override
public float mass() {
return 40f;
}
});
SimpleSpatial neck;
add(neck = new SimpleSpatial("neck") {
@Override
protected CollisionShape newShape() {
// return new TetrahedronShapeEx(v(0,10,0), v(10,0,0), v(10,10,0), v(0,0,10));
return new CylinderShape(v(0.25f, 0.75f, 0.25f));
}
@Override
protected Body3D create(Dynamics3D world) {
torso.body.clearForces();
Body3D n = super.create(world);
HingeConstraint p = new HingeConstraint(torso.body, body, v(0, 0.2f, 0), v(0, -1f, 0), v(1, 0, 0), v(1, 0, 0));
p.setLimit(-1.0f, 1.0f);
add(p);
return n;
}
@Override
public float mass() {
return 10f;
}
});
neck.shapeColor[0] = 1f;
neck.shapeColor[1] = 0.1f;
neck.shapeColor[2] = 0.5f;
neck.shapeColor[3] = 1f;
RetinaGrid rg = new RetinaGrid("cam1", v(), v(0, 0, 1), v(0.1f, 0, 0), v(0, 0.1f, 0), 6, 6, 4f) {
@Override
protected Body3D create(Dynamics3D world) {
Body3D l = super.create(world);
// move(0,-1,0);
// body.clearForces();
l.clearForces();
HingeConstraint p = new HingeConstraint(neck.body, body, v(0, 0.6f, 0), v(0, -0.6f, 0), v(0, 1, 0), v(0, 1, 0));
p.setLimit(-0.75f, 0.75f);
// Point2PointConstraint p = new Point2PointConstraint(body, torso.body, v(2, 0, 0), v(-2, 0, 0));
// p.impulseClamp = 0.01f;
// //p.damping = 0.5f;
// p.tau = 0.01f;
add(p);
return l;
}
};
add(rg);
}
};
// new SpaceGraph<>(
// new Maze("x", 20, 20),
// r
// );//.setGravity(v(0, 0, -5)).show(1000, 1000);
}
use of nars.NARS in project narchy by automenta.
the class SATStream method main.
public static void main(String[] args) throws Narsese.NarseseException {
// this.activeTasks = activeTasks;
NAR d = new NARS().get();
// d.inputActivation.setValue(0.2f);
d.log();
d.input("$0.1;0.2;0.5$ T:x1. :|:", "$0.1;0.2;0.5$ T:x2. :|:", "$0.1;0.2;0.5$ T:(--,x3). :|:", "$0.1;0.2;0.5$ T:(--,x4). :|:", "$1.0;1.0;1.0$ (($c:$x && $c:$y) ==> AND({$x,$y})). %1.00;1.00%");
d.run(10360);
// d.dumpConcepts("/tmp/x.txt");
}
use of nars.NARS in project narchy by automenta.
the class TrieDeriverTest method test.
public TestNAR test(int tlMax, boolean debug, String... rules) {
NAR n = new NARS().deriverAddRules(rules).get();
TestNAR t = new TestNAR(n);
tests.add(t);
return t;
}
Aggregations