Search in sources :

Example 41 with TestNAR

use of nars.test.TestNAR in project narchy by automenta.

the class NAL7Test method induction_on_events_composition_post.

@ValueSource(ints = { 0, 1, 2, 3, 4 })
@ParameterizedTest
public void induction_on_events_composition_post(int dt) {
    TestNAR tester = test;
    int t = 0;
    String component = "(open(John,door) &| hold(John,key))";
    tester.inputAt(t, component + ". :|:");
    tester.inputAt(t + dt, "enter(John,room). :|:");
    tester.mustBelieve((2 * (t + Math.max(2, dt)) + Math.max(2, dt) + 1), /**
     * approx
     */
    "(" + component + " ==>+" + dt + " enter(John,room))", 1.00f, 0.45f, t);
}
Also used : TestNAR(nars.test.TestNAR) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 42 with TestNAR

use of nars.test.TestNAR in project narchy by automenta.

the class NAL7Test method testPrediction1.

@Test
public void testPrediction1() throws Narsese.NarseseException {
    int eventDT = 16;
    int cycles = 10;
    TestNAR t = test;
    // ((FrameTime)t.nar.time).dur(eventDT);
    t.dur(eventDT / 2);
    // t.nar.onTask((tt)->{
    // if (tt.start() > t.nar.time()) {
    // System.out.println(tt.proof());
    // }
    // });
    int x = 0;
    for (int i = 0; i < cycles; i++) {
        if (i == cycles - 1) {
            $.task($("(y)"), QUESTION, null).time(0, x, x + 2 * eventDT).setPriThen(1f).apply(t.nar);
        }
        t.inputAt(x, "(x). :|:").inputAt(x + eventDT, "(y). :|:");
        x += 2 * eventDT;
    }
    int xx = x;
    t.mustBelieve(x - 1, "(y)", 1f, 0.73f, (y) -> y >= xx && y <= (xx + eventDT));
}
Also used : TestNAR(nars.test.TestNAR) NALTest(nars.util.NALTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 43 with TestNAR

use of nars.test.TestNAR in project narchy by automenta.

the class NAL7Test method temporal_explification.

@Test
public void temporal_explification() {
    TestNAR tester = test;
    tester.believe("(<($x, room) --> enter> ==>-5 <($x, door) --> open>)", 0.9f, 0.9f);
    tester.believe("(<($y, door) --> open> ==>-5 <($y, key) --> hold>)", 0.8f, 0.9f);
    tester.mustBelieve(cycles, "(<($1,key) --> hold> ==>+10 <($1,room) --> enter>)", 1.00f, 0.37f);
}
Also used : TestNAR(nars.test.TestNAR) NALTest(nars.util.NALTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 44 with TestNAR

use of nars.test.TestNAR in project narchy by automenta.

the class LinkageTest method ProperlyLinkedIndirectlyLayer2Test.

// interlinked with an intermediate concept, this is needed in order to select one as task and the other as belief
public void ProperlyLinkedIndirectlyLayer2Test(@NotNull String premise1, @NotNull String premise2) throws Exception {
    TestNAR tester = test;
    // .en("If robin is a type of bird then robin can fly.");
    tester.believe(premise1);
    // .en("Robin is a type of bird.");
    tester.believe(premise2);
    tester.nar.run(1);
    boolean passed = links(premise1, premise2, tester);
    boolean passed2 = links(premise2, premise1, tester);
    assertTrue(passed);
    assertTrue(passed2);
    // dummy
    tester.believe("<a --> b>");
    tester.mustBelieve(1, "<a --> b>", 0.9f);
}
Also used : TestNAR(nars.test.TestNAR)

Example 45 with TestNAR

use of nars.test.TestNAR in project narchy by automenta.

the class LinkageTest method ProperlyLinkedTest.

void ProperlyLinkedTest(@NotNull String premise1, @NotNull String premise2) throws Exception {
    test.requireConditions = false;
    TestNAR tester = test;
    // .en("If robin is a type of bird then robin can fly.");
    tester.believe(premise1);
    // .en("Robin is a type of bird.");
    tester.believe(premise2);
    tester.run(runCycles, false);
    Concept ret = tester.nar.conceptualize(premise1);
    assertTrue(isPassed2(premise2, ret), ret + " termlinks contains " + premise2);
    Concept ret2 = tester.nar.conceptualize(premise2);
    assertTrue(isPassed2(premise1, ret2), ret2 + " termlinks contains " + premise1);
}
Also used : Concept(nars.concept.Concept) TestNAR(nars.test.TestNAR)

Aggregations

TestNAR (nars.test.TestNAR)178 Test (org.junit.jupiter.api.Test)169 NALTest (nars.util.NALTest)162 NAL7Test (nars.nal.nal7.NAL7Test)18 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)11 Disabled (org.junit.jupiter.api.Disabled)5 NAR (nars.NAR)2 Concept (nars.concept.Concept)2 DoubleSummaryStatistics (java.util.DoubleSummaryStatistics)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 BiFunction (java.util.function.BiFunction)1 IntFunction (java.util.function.IntFunction)1 nars (nars)1 NARS (nars.NARS)1 TaskStatistics (nars.task.util.TaskStatistics)1 Term (nars.term.Term)1 DeductiveMeshTest (nars.test.DeductiveMeshTest)1 ETERNAL (nars.time.Tense.ETERNAL)1 NotNull (org.jetbrains.annotations.NotNull)1 Assertions.assertNotEquals (org.junit.jupiter.api.Assertions.assertNotEquals)1