Search in sources :

Example 16 with TaskConcept

use of nars.concept.TaskConcept in project narchy by automenta.

the class DynamicTruthBeliefTableTest method testDynamicConjunction3.

@Test
public void testDynamicConjunction3() throws Narsese.NarseseException {
    NAR n = NARS.tmp();
    n.believe("a:x", 1f, 0.9f);
    n.believe("a:y", 1f, 0.9f);
    n.believe("a:z", 1f, 0.9f);
    n.run(1);
    TaskConcept cc = (TaskConcept) n.conceptualize($("(&&, a:x, a:y, a:z)"));
    Truth now = n.beliefTruth(cc, n.time());
    assertNotNull(now);
    assertTrue($.t(1f, 0.73f).equals(now, 0.1f), now + " truth at " + n.time());
    // the truth values were provided despite the belief tables being empty:
    // test unknown:
    {
        TaskConcept ccn = (TaskConcept) n.conceptualize($("(&&, a:x, a:w)"));
        Truth nown = n.beliefTruth(ccn, n.time());
        assertNull(nown);
    }
    // test negation:
    Concept ccn = n.conceptualize($("(&&, a:x, (--, a:y), a:z)"));
    {
        Task t = n.belief(ccn.term());
        assertNotNull(t);
        // the critical component
        assertEquals($("a:y"), t.term());
        assertEquals(1f, t.freq());
    }
    assertTrue(ccn instanceof TaskConcept);
    Truth nown = n.beliefTruth(ccn, n.time());
    assertEquals("%0.0;.90%", nown.toString());
    n.clear();
    // test change after a component's revision to negate the input freq
    n.believe("a:y", 0, 0.95f);
    n.run(1);
    n.concept("a:y").print();
    Task ay = n.belief($$("a:y"));
    assertTrue(ay.freq() < 0.5f);
    Task bb = n.belief(n.conceptualize($("(&&, a:x, a:y, a:z)")), n.time());
    Truth now2 = bb.truth();
    assertTrue(now2.freq() < 0.4f);
}
Also used : TaskConcept(nars.concept.TaskConcept) Concept(nars.concept.Concept) TaskConcept(nars.concept.TaskConcept) Truth(nars.truth.Truth) Test(org.junit.jupiter.api.Test)

Aggregations

TaskConcept (nars.concept.TaskConcept)16 Test (org.junit.jupiter.api.Test)11 Concept (nars.concept.Concept)5 Term (nars.term.Term)4 Truth (nars.truth.Truth)4 RTreeBeliefTable (nars.table.RTreeBeliefTable)3 Collectors.toList (java.util.stream.Collectors.toList)2 nars (nars)2 NAR (nars.NAR)2 BELIEF (nars.Op.BELIEF)2 BeliefTable (nars.table.BeliefTable)2 Termed (nars.term.Termed)2 TestNAR (nars.test.TestNAR)2 Tense (nars.time.Tense)2 Iterables (com.google.common.collect.Iterables)1 Lists (com.google.common.collect.Lists)1 GL2 (com.jogamp.opengl.GL2)1 java.awt (java.awt)1 Rectangle2D (java.awt.geom.Rectangle2D)1 BufferedImage (java.awt.image.BufferedImage)1