Search in sources :

Example 16 with NAR

use of nars.NAR in project narchy by automenta.

the class ImplicationNetworkTest method testEternal_A_PosGoal_ToBC.

@Test
public void testEternal_A_PosGoal_ToBC() {
    NAR n = NARS.tmp();
    Param.DEBUG = true;
    n.believe(IMPL.the(a, b));
    n.believe(IMPL.the(b, c));
    n.goal(a);
    n.run(100);
    BeliefTable aGoals = n.concept(a).goals();
    Truth aGoal = aGoals.truth(ETERNAL, n);
    // n.concept(a).print();
    // a belief state should not exceed the input (default confidence) and freq remain stable
    // additional beliefs are not helpful
    assertEquals(1, aGoals.size());
    BeliefTable bGoals = n.concept(b).goals();
    Truth bGoal = bGoals.truth(ETERNAL, n);
    n.concept(b).print();
    assertEquals(1, bGoals.size());
    // b should have less conf than a but higher than c
    // same freq among all
    BeliefTable cGoals = n.concept(c).goals();
    Truth cGoal = cGoals.truth(ETERNAL, n);
    n.concept(c).print();
    // assertEquals(1, cGoals.size());
    System.out.println("a: " + aGoal);
    System.out.println("b: " + bGoal);
    System.out.println("c: " + cGoal);
    assertEquals(aGoal.freq(), bGoal.freq(), n.freqResolution.floatValue());
    assertEquals(bGoal.freq(), cGoal.freq(), n.freqResolution.floatValue());
    assertTrue(aGoal.conf() - bGoal.conf() > n.confResolution.floatValue() * 2);
    assertTrue(bGoal.conf() - cGoal.conf() > n.confResolution.floatValue() * 2);
}
Also used : BeliefTable(nars.table.BeliefTable) NAR(nars.NAR) Truth(nars.truth.Truth) Test(org.junit.jupiter.api.Test)

Example 17 with NAR

use of nars.NAR in project narchy by automenta.

the class LinkageTest method Variable_Normalization_1.

// @Test
// public void Advanced_Concept_Formation_Test4() throws Exception {
// testConceptFormed("(&&,<#1 --> (/,open,#2,_)>,<#1 --> lock>,<#2 --> key>)");
// }
@Test
public void Variable_Normalization_1() throws Exception {
    // this.activeTasks = activeTasks;
    NAR tester = NARS.tmp();
    test.requireConditions = false;
    String nonsense = "<(&&,<#1 --> M>,<#2 --> M>) ==> <#1 --> nonsense>>";
    // .en("If robin is a type of bird then robin can fly.");
    tester.believe(nonsense);
    tester.run(1);
    Concept c = tester.conceptualize(nonsense);
    assertNotNull(c);
}
Also used : Concept(nars.concept.Concept) TestNAR(nars.test.TestNAR) NAR(nars.NAR) NALTest(nars.util.NALTest) Test(org.junit.jupiter.api.Test)

Example 18 with NAR

use of nars.NAR in project narchy by automenta.

the class STRIPSTest method testBanana1.

@Test
public void testBanana1() throws Narsese.NarseseException {
    NAR n = new NARS().tmp();
    n.log();
    n.input("At(A). :|:", "Level(low). :|:", "BoxAt(C). :|:", "BananasAt(B). :|:", /* Goal state:    Eat(bananas) */
    "Eat(bananas)!", // _Move(X, Y)_
    "((At($X) &&+0 Level(low)) ==>+1 (--At($X) &&+0 At(#Y))).", // _ClimbUp(Location)_ climb up the box
    "(((At(#Location) &&+0 BoxAt(#Location)) &&+0 Level(low)) ==>+1 (Level(high) &&+0 --Level(low))).", // _ClimbDown(Location)_ climb down from the box
    "(((At(#Location) &&+0 BoxAt(#Location)) &&+0 Level(high)) ==>+1 (Level(low), --Level(high))).", /* Preconditions:  At(X), BoxAt(X), Level(low)
               Postconditions: BoxAt(Y), not BoxAt(X), At(Y), not At(X) */
    "(((At($X) &&+0 BoxAt($X)) &&+0 Level(low)) ==>+1 ((((At(#Y) &&+0 BoxAt(#Y)) &&+0 --BoxAt($X)) &&+0 --At($X)))).", /* Preconditions:  At(Location), BananasAt(Location), Level(high)
               Postconditions: Eat(bananas) */
    "(((At(#Location) &&+0 BananasAt(#Location)) &&+0 Level(high)) ==>+1 Eat(bananas)).");
    n.run(1000);
}
Also used : NARS(nars.NARS) NAR(nars.NAR) Test(org.junit.jupiter.api.Test)

Example 19 with NAR

use of nars.NAR in project narchy by automenta.

the class ListFuncTest method testTestResult.

@Test
public void testTestResult() {
    NAR n = NARS.shell();
    assertEquals(Set.of($$("append((x),(y),(x,y))")), Solution.solve($$("append((x),(y),(x,y))"), n.concepts.functors));
    assertEquals(Set.of($$("append(x,y,(x,y))")), Solution.solve($$("append(x,y,(x,y))"), n.concepts.functors));
    assertEquals(Set.of(False), Solution.solve($$("append((x),(y),(x,y,z))"), n.concepts.functors));
}
Also used : NAR(nars.NAR) Test(org.junit.jupiter.api.Test)

Example 20 with NAR

use of nars.NAR in project narchy by automenta.

the class ListFuncTest method testAppendHeadAndTail.

@Test
public void testAppendHeadAndTail() {
    NAR n = NARS.shell();
    assertEquals(Set.of($$("append((x,y,z),(),(x,y,z))"), $$("append((x,y),(z),(x,y,z))"), $$("append((x),(y,z),(x,y,z))"), $$("append((),(x,y,z),(x,y,z))")), Solution.solve($$("append(#x,#y,(x,y,z))"), n.concepts.functors));
}
Also used : NAR(nars.NAR) Test(org.junit.jupiter.api.Test)

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