Search in sources :

Example 81 with NAR

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());
}
Also used : BeliefTable(nars.table.BeliefTable) NAR(nars.NAR) Truth(nars.truth.Truth) Test(org.junit.jupiter.api.Test)

Example 82 with NAR

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());
}
Also used : BeliefTable(nars.table.BeliefTable) NAR(nars.NAR) Truth(nars.truth.Truth) Test(org.junit.jupiter.api.Test)

Example 83 with NAR

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);
}
Also used : BeliefTable(nars.table.BeliefTable) NAR(nars.NAR) Truth(nars.truth.Truth) Test(org.junit.jupiter.api.Test)

Example 84 with NAR

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)?");
}
Also used : NARS(nars.NARS) NAR(nars.NAR) Test(org.junit.jupiter.api.Test)

Example 85 with NAR

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());
}
Also used : NAR(nars.NAR) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Aggregations

NAR (nars.NAR)124 Test (org.junit.jupiter.api.Test)92 NARS (nars.NARS)23 Term (nars.term.Term)20 Truth (nars.truth.Truth)18 TestNAR (nars.test.TestNAR)16 BeliefTable (nars.table.BeliefTable)10 Disabled (org.junit.jupiter.api.Disabled)9 PrologCore (nars.op.prolog.PrologCore)8 Nullable (org.jetbrains.annotations.Nullable)8 Task (nars.Task)7 Concept (nars.concept.Concept)6 Param (nars.Param)5 Termed (nars.term.Termed)5 List (java.util.List)4 FasterList (jcog.list.FasterList)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 nars.$ (nars.$)3 ITask (nars.task.ITask)3 NALTest (nars.util.NALTest)3