Search in sources :

Example 26 with Concept

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

the class TemporalTermTest method testAtemporalization.

@Test
public void testAtemporalization() throws Narsese.NarseseException {
    Term t = $("((x) ==>+10 (y))");
    Concept c = n.conceptualize(t);
    assertEquals("((x)==>(y))", c.toString());
}
Also used : TaskConcept(nars.concept.TaskConcept) Concept(nars.concept.Concept) Test(org.junit.jupiter.api.Test)

Example 27 with Concept

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

the class TemporalTermTest method testCommutiveTemporalityConcepts2.

@Test
public void testCommutiveTemporalityConcepts2() throws Narsese.NarseseException {
    NAR n = NARS.shell();
    for (String op : new String[] { "&&" }) {
        Concept a = n.conceptualize($("(x " + op + "   y)"));
        Concept b = n.conceptualize($("(x " + op + "+1 y)"));
        assertSame(a, b);
        Concept c = n.conceptualize($("(x " + op + "+2 y)"));
        assertSame(b, c);
        Concept d = n.conceptualize($("(x " + op + "-1 y)"));
        assertSame(c, d);
        Term e0 = $("(x " + op + "+- y)");
        assertEquals("(x " + op + "+- y)", e0.toString());
        Concept e = n.conceptualize(e0);
        assertSame(d, e);
        Term f0 = $("(y " + op + "+- x)");
        assertEquals("(x " + op + "+- y)", f0.toString());
        assertEquals("(x" + op + "y)", f0.root().toString());
        Concept f = n.conceptualize(f0);
        assertSame(e, f, e + "==" + f);
        // repeat
        Concept g = n.conceptualize($("(x " + op + "+- x)"));
        assertEquals("(x " + op + "+- x)", g.toString());
        // co-negation
        Concept h = n.conceptualize($("(x " + op + "+- (--,x))"));
        assertEquals("((--,x) " + op + "+- x)", h.toString());
    }
}
Also used : TaskConcept(nars.concept.TaskConcept) Concept(nars.concept.Concept) Test(org.junit.jupiter.api.Test)

Example 28 with Concept

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

the class BeliefTableChart method renderTable.

private void renderTable(Concept c, long minT, long maxT, long now, GL2 gl, TruthWave wave, boolean beliefOrGoal) {
    if (c == null)
        return;
    float nowX = xTime(minT, maxT, now);
    // Present axis line
    if ((now <= maxT) && (now >= minT)) {
        gl.glColor4f(1f, 1f, 1f, 0.5f);
        Draw.line(gl, nowX, 0, nowX, 1);
    // float nowLineWidth = 0.005f;
    // Draw.rect(gl, nowX - nowLineWidth / 2f, 0, nowLineWidth, 1);
    }
    /**
     * drawn "pixel" dimensions
     */
    renderWave(nowX, minT, maxT, gl, wave, beliefOrGoal);
    // draw projections
    if (projections > 0 && minT != maxT) {
        for (boolean freqOrExp : new boolean[] { true, false }) {
            TruthWave pwave = beliefOrGoal ? beliefProj : goalProj;
            // HACK dont show expectation for beliefs
            if (beliefOrGoal && !freqOrExp)
                continue;
            Colorize colorize;
            if (freqOrExp) {
                colorize = beliefOrGoal ? (ggl, frq, cnf) -> {
                    float a = 0.65f + 0.2f * cnf;
                    ggl.glColor4f(0.25f + 0.75f * cnf, 0.1f * (1f - cnf), 0, a);
                } : (ggl, frq, cnf) -> {
                    float a = 0.65f + 0.2f * cnf;
                    ggl.glColor4f(0.1f * (1f - cnf), 0.25f + 0.75f * cnf, 0, a);
                };
            } else {
                colorize = beliefOrGoal ? (ggl, frq, cnf) -> {
                    ggl.glColor4f(cnf, cnf / 2f, 0.25f, 0.85f);
                } : (ggl, frq, cnf) -> {
                    ggl.glColor4f(cnf / 2f, cnf, 0.25f, 0.85f);
                };
            }
            FloatFloatToFloatFunction y = freqOrExp ? (frq, cnf) -> frq : TruthFunctions::expectation;
            // HACK show goal freq in thinner line
            gl.glLineWidth((freqOrExp && !beliefOrGoal) ? 2f : 4f);
            renderWaveLine(nowX, minT, maxT, gl, pwave, y, colorize);
        }
    }
    float chSize = 0.1f;
    Truth bc = wave.current;
    if (bc != null) {
        float theta;
        float expectation = bc.expectation();
        float dTheta = (expectation - 0.5f) * angleSpeed;
        float conf = bc.conf();
        if (beliefOrGoal) {
            this.beliefTheta += dTheta;
            theta = beliefTheta;
            gl.glColor4f(1f, 0f, 0, 0.2f + 0.8f * conf);
            drawCrossHair(gl, nowX, chSize, bc.freq(), conf, theta);
        } else {
            this.goalTheta += dTheta;
            theta = goalTheta;
            // //freq
            // gl.glColor4f(0f, 1f, 0, 0.2f + 0.8f * conf);
            // drawCrossHair(gl, nowX, chSize, bc.freq(), conf, theta);
            // expectation
            gl.glColor4f(0f, 1f, 0, 0.2f + 0.8f * conf);
            drawCrossHair(gl, nowX, chSize, expectation, expectation, theta);
        }
    }
}
Also used : GL2(com.jogamp.opengl.GL2) DurService(nars.control.DurService) PushButton(spacegraph.space2d.widget.button.PushButton) BiFunction(java.util.function.BiFunction) Surface(spacegraph.space2d.Surface) ETERNAL(nars.time.Tense.ETERNAL) Draw(spacegraph.video.Draw) Util(jcog.Util) RectFloat2D(jcog.tree.rtree.rect.RectFloat2D) TruthWave(nars.truth.TruthWave) MetaFrame(spacegraph.space2d.widget.meta.MetaFrame) TruthFunctions(nars.truth.TruthFunctions) BeliefTable(nars.table.BeliefTable) Task(nars.Task) Truth(nars.truth.Truth) NAR(nars.NAR) Gridding(spacegraph.space2d.container.Gridding) Termed(nars.term.Termed) PI(java.lang.Math.PI) TaskConcept(nars.concept.TaskConcept) Concept(nars.concept.Concept) Label(spacegraph.space2d.widget.text.Label) FloatFloatToFloatFunction(jcog.util.FloatFloatToFloatFunction) Term(nars.term.Term) FloatFloatToFloatFunction(jcog.util.FloatFloatToFloatFunction) TruthFunctions(nars.truth.TruthFunctions) TruthWave(nars.truth.TruthWave) Truth(nars.truth.Truth)

Example 29 with Concept

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

the class ConceptView method update.

protected void update() {
    Concept c = nar.concept(term);
    if (c != null) {
        sa.setLength(0);
        c.print(sa, false, false, true, false);
        io.term.clearScreen();
        io.text.append(sa);
        io.term.flush();
    } else {
        io.term.clearScreen();
        try {
            io.text.append(String.valueOf(term)).append(" unconceptualized");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
Also used : Concept(nars.concept.Concept) IOException(java.io.IOException)

Example 30 with Concept

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

the class DynamicConceptSpace method get.

@Override
protected List<ConceptWidget> get() {
    if (updated.get()) {
        List<ConceptWidget> w;
        w = next.write();
        w.clear();
        concepts.forEach((clink) -> {
            // ConceptWidget cw = space.getOrAdd(clink.get().id, ConceptWidget::new);
            Concept cc = clink.get().id;
            ConceptWidget cw = cc.meta(spaceID, (sid) -> new ConceptWidget(cc) {

                @Override
                protected void onClicked(PushButton b) {
                    SpaceGraph.window(new ConceptSurface(id.term(), nar), 800, 700);
                }
            });
            if (cw != null) {
                cw.activate();
                cw.pri = clink.priElseZero();
                w.add(cw);
            }
        // space.getOrAdd(concept.term(), materializer).setConcept(concept, now)
        });
        vis.accept(next.write());
        next.commit();
        updated.set(false);
    }
    return next.read();
}
Also used : Concept(nars.concept.Concept) ConceptSurface(nars.gui.ConceptSurface) PushButton(spacegraph.space2d.widget.button.PushButton)

Aggregations

Concept (nars.concept.Concept)47 TaskConcept (nars.concept.TaskConcept)19 Term (nars.term.Term)19 Test (org.junit.jupiter.api.Test)15 Nullable (org.jetbrains.annotations.Nullable)11 Truth (nars.truth.Truth)9 NAR (nars.NAR)6 Termed (nars.term.Termed)6 FasterList (jcog.list.FasterList)4 PermanentConcept (nars.concept.PermanentConcept)4 BeliefTable (nars.table.BeliefTable)4 TestNAR (nars.test.TestNAR)4 Util (jcog.Util)3 PriReference (jcog.pri.PriReference)3 GL2 (com.jogamp.opengl.GL2)2 java.io (java.io)2 java.util (java.util)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 Op (nars.Op)2 CauseLink (nars.link.CauseLink)2