use of nars.NAR in project narchy by automenta.
the class TemporalInductionTest method testQuestionProjection.
@Test
public void testQuestionProjection() throws Narsese.NarseseException {
NAR n = NARS.tmp();
n.log();
n.input("a:b. :|:");
// n.frame();
n.input("a:b? :/:");
n.run(5);
n.input("a:b? :/:");
n.run(30);
n.input("a:b? :/:");
n.run(250);
n.input("a:b? :/:");
n.run(1);
// n.forEachConcept(Concept::print);
// Concept c = n.concept("a:b");
// assertEquals("(b-->a). 5+0 %.50;.95%", c.getBeliefs().top().toStringWithoutBudget());
}
use of nars.NAR in project narchy by automenta.
the class TemporalInductionTest method testTemporalRevision.
@Test
public void testTemporalRevision() throws Narsese.NarseseException {
NAR n = NARS.tmp();
n.time.dur(1);
n.log();
// TextOutput.out(n);
n.input("a:b. %1.0|0.9%");
n.run(5);
n.input("a:b. %0.0|0.9%");
n.run(5);
n.input("a:b. %0.5|0.9%");
n.run(1);
// n.forEachConcept(Concept::print);
TaskConcept c = (TaskConcept) n.conceptualize("a:b");
assertNotNull(c);
// assertEquals("(b-->a). 5+0 %.50;.95%", c.getBeliefs().top(n.time()).toStringWithoutBudget());
BeliefTable b = c.beliefs();
b.print();
assertTrue(3 <= b.size());
// when originality is considered:
// assertEquals("(b-->a). 5+0 %0.0;.90%", c.beliefs().top(n.time()).toStringWithoutBudget());
// most current relevant overall:
assertEquals("(b-->a). 5 %0.0;.90%", n.belief(c.term(), 5).toStringWithoutBudget());
// least relevant
assertEquals("(b-->a). 0 %1.0;.90%", n.belief(c.term(), 0).toStringWithoutBudget());
}
use of nars.NAR in project narchy by automenta.
the class TemporalInductionTest method testPriorityOfInductedRulesVsEventsThatItLearnedFrom.
/**
* higher-level rules learned from events, especially repeatd
* events, "should" ultimately accumulate a higher priority than
* the events themselves.
*/
@Test
public void testPriorityOfInductedRulesVsEventsThatItLearnedFrom() throws FileNotFoundException {
NAR n = NARS.tmp();
n.beliefPriDefault.set(0.1f);
// n.deep.set(1f);
n.log();
TemporalMetrics m = new TemporalMetrics(1024);
n.onCycle(() -> m.update(n.time()));
m.add(new PriMeter(n, "(0)"));
m.add(new PriMeter(n, "(1)"));
m.add(new PriMeter(n, "(2)"));
m.add(new PriMeter(n, "((0) && (1))"));
m.add(new PriMeter(n, "((0) ==> (1))"));
m.add(new PriMeter(n, "((1) && (2))"));
m.add(new PriMeter(n, "((1) ==> (2))"));
// expose to repeat sequence
int loops = 32, eventsPerLoop = 3, delayBetweenEvents = 2;
for (int i = 0; i < loops; i++) {
for (int j = 0; j < eventsPerLoop; j++) {
n.believe($.p(j), Tense.Present);
n.run(delayBetweenEvents);
}
}
m.printCSV4("/tmp/x.csv");
m.printCSV4(System.out);
}
use of nars.NAR in project narchy by automenta.
the class TemporalInductionTest method testTemporalInduction.
@Test
public void testTemporalInduction() throws Narsese.NarseseException {
String task = "<a --> b>. :|:";
String task2 = "<c --> d>. :|:";
NAR n = NARS.tmp();
// TextOutput.out(n);
n.input(task);
n.run(10);
n.input(task2);
n.run(10);
}
use of nars.NAR in project narchy by automenta.
the class ImplicationTest method testGoal.
@Test
public void testGoal() {
// Z, X==>Y
StringBuilder o = new StringBuilder();
for (boolean sp : B) {
Term z = sp ? x : y;
for (boolean zz : B) {
for (boolean xx : B) {
for (boolean yy : B) {
NAR n = NARS.tmp();
Term cond = z.negIf(!zz);
Term impl = IMPL.the(x.negIf(!xx), y.negIf(!yy));
n.believe(impl);
n.goal(cond);
n.run(64);
Term nz = sp ? y : x;
@Nullable Truth nzt = n.goalTruth(nz, ETERNAL);
o.append(cond + "! " + impl + ". " + nz + "=" + nzt + "\n");
}
}
}
}
String oo = o.toString();
System.out.println(oo);
// strong
assertContains(oo, "y! (x==>y). x=%1.0;.81%");
assertContains(oo, "y! ((--,x)==>y). x=%0.0;.81%");
assertContains(oo, "(--,y)! (--,(x==>y)). x=%1.0;.81%");
assertContains(oo, "(--,y)! (--,((--,x)==>y)). x=%0.0;.81%");
// weak
assertContains(oo, "x! (x==>y). y=%1.0;.45%");
assertContains(oo, "x! (--,(x==>y)). y=%0.0;.45%");
// ...
}
Aggregations