use of nars.NAR in project narchy by automenta.
the class ImplicationNetworkTest method testEternal_A_NegBelief_NegToBC_AB_only.
@Test
public void testEternal_A_NegBelief_NegToBC_AB_only() {
NAR n = NARS.tmp(6);
n.termVolumeMax.set(16);
Param.DEBUG = true;
n.believe(IMPL.the(a.neg(), b));
n.believe(a.neg());
n.run(100);
BeliefTable aa = n.concept(a).beliefs();
BeliefTable bb = n.concept(b).beliefs();
aa.print();
// bb.print();
bb.forEachTask(x -> System.out.println(x.proof()));
Truth bBelief = bb.truth(ETERNAL, n);
assertEquals("%1.0;.81%", bBelief.toString());
}
use of nars.NAR in project narchy by automenta.
the class ImplicationNetworkTest method testEternal_A_NegBelief_NegToB_NegToC.
@Test
public void testEternal_A_NegBelief_NegToB_NegToC() {
NAR n = NARS.tmp();
n.log();
Param.DEBUG = true;
n.believe(IMPL.the(a.neg(), b).neg());
n.believe(IMPL.the(b.neg(), c));
n.believe(a.neg());
n.run(100);
BeliefTable aBeliefs = n.concept(a).beliefs();
aBeliefs.print();
// assertEquals(1, aBeliefs.size());
Truth bBelief = n.concept(b).beliefs().truth(ETERNAL, n);
Truth cBelief = n.concept(c).beliefs().truth(ETERNAL, n);
assertEquals("%0.0;.81%", bBelief.toString());
assertEquals("%1.0;.73%", cBelief.toString());
}
use of nars.NAR in project narchy by automenta.
the class ImplicationNetworkTest method testEternal_A_NegBelief_ToBC.
@Test
public void testEternal_A_NegBelief_ToBC() {
NAR n = NARS.tmp();
Param.DEBUG = true;
n.believe(IMPL.the(a, b));
n.believe(IMPL.the(b, c));
n.believe(a.neg());
n.run(100);
BeliefTable aBeliefs = n.concept(a).beliefs();
// Truth aBelief = aBeliefs.truth(ETERNAL, n);
// a belief state should not exceed the input (default confidence) and freq remain stable
// additional beliefs are not helpful
// assertEquals(1, aBeliefs.size());
Truth bBelief = n.concept(b).beliefs().truth(ETERNAL, n);
// NOTHING
assertNull(bBelief);
}
use of nars.NAR in project narchy by automenta.
the class MathTest method testImplVarAdd1.
// @Test
// public void testAdd1() {
// Terminal t = NARS.shell();
// t.log();
// t.input("(add(1,2,?x)<->result).");
// t.next();
// }
@Test
public void testImplVarAdd1() throws Narsese.NarseseException {
Param.DEBUG = true;
NAR t = new NARS().get();
// t.log();
// t.input("i:{0,1,2,3,4}.");
// t.input("i:{0,1,2}.");
t.input("i:{1}.");
t.input("i:{2}.");
t.input("i:{4}.");
t.input("((&&,({$x} --> i),({$y} --> i)) ==> ({($x,$y),($y,$x)} --> j)).");
t.run(100);
t.input("(({(#x,#y)} --> j) ==> ({add(#x,#y)} --> i)).");
t.run(100);
// t.input("(({#x,#y} --> i) && (add(#x,#y)<->sum)).");
// t.input("(({$x,$y} --> i) ==> (add($x,$y)<->sum)).");
// t.input("(&&,({$x} --> i),({$y} --> i),({add($x,$y)}-->i)).");
// /t.input("(((#x --> i)&&(#y --> i)) ==> (add(#x,#y)<->sum)).");
// t.input("((($x --> i)&&($y --> i)) ==> (add($x,$y)<->sum)).");
// t.input("(({?x,?y} --> i) ==> (add(?x,?y)<->sum))?");
// t.input("({?x}-->i)?");
}
use of nars.NAR in project narchy by automenta.
the class NARTest method testMemoryTransplant.
// @Test
// public void testEmptyMemoryToJSON() throws IOException, InterruptedException, ClassNotFoundException {
// Memory m = NARS.shell().memory;
// String j = JSON.omDeep.writeValueAsString(m);
// assertTrue(j.length() > 16);
//
// String pretty = JSON.omDeep.writerWithDefaultPrettyPrinter().writeValueAsString(m);
// System.out.println(pretty);
//
// assertTrue(pretty.length() > j.length() );
// }
//
// @Test
// public void testEmptyMemorySerialization() throws IOException, InterruptedException, ClassNotFoundException {
// /** empty memory, and serialize it */
// Memory m = new Default2(1024,1,1,1).memory;
// byte[] bm = m.toBytes();
// assertTrue(bm.length > 64);
//
// assertEquals(m, new JBossMarshaller().objectFromByteBuffer(bm) );
//
// }
@Test
@Disabled
public void testMemoryTransplant() throws Narsese.NarseseException {
// this.activeTasks = activeTasks;
NAR nar = NARS.tmp();
// DefaultAlann nar = new DefaultAlann(m, 32);
// TextOutput.out(nar);
nar.input("<a-->b>.", "<b-->c>.").run(25);
nar.input("<a-->b>.", "<b-->c>.");
nar.stop();
assertTrue(nar.concepts.size() > 5);
int nc;
assertTrue((nc = nar.concepts.size()) > 0);
// a new nar with the same memory is allowed to
// take control of it after the first stops
// this.activeTasks = activeTasks;
NAR nar2 = NARS.tmp();
assertTrue(nar.time() > 1);
// it should have existing concepts
assertEquals(nc, nar2.concepts.size());
}
Aggregations