Search in sources :

Example 36 with Task

use of nars.Task in project narchy by automenta.

the class NarseseBaseTest method testNoBudget.

@Test
public void testNoBudget() throws Narsese.NarseseException {
    Task t = task("<a ==> b>. %0.00;0.93");
    assertNotNull(t);
    assertEquals(Op.IMPL, t.op());
    assertEquals('.', t.punc());
    // assertEquals(Global.DEFAULT_JUDGMENT_PRIORITY, t.getPriority(), 0.001);
    // assertEquals(Global.DEFAULT_JUDGMENT_DURABILITY, t.getDurability(), 0.001);
    assertEquals(0.0f, t.freq(), 0.001);
    assertEquals(0.93f, t.conf(), 0.001);
}
Also used : Task(nars.Task) Test(org.junit.jupiter.api.Test)

Example 37 with Task

use of nars.Task in project narchy by automenta.

the class NarseseBaseTest method testQuest.

@Test
public void testQuest() throws Narsese.NarseseException {
    String tt = "(a,b,c)";
    Task t = task(tt + '@');
    assertNotNull(t);
    assertEquals(PROD, t.op());
    assertEquals(tt, t.term().toString());
    assertEquals('@', t.punc());
    assertNull(t.truth());
}
Also used : Task(nars.Task) Test(org.junit.jupiter.api.Test)

Example 38 with Task

use of nars.Task in project narchy by automenta.

the class BeliefTableChart method draw.

protected void draw(Termed tt, Concept cc, GL2 gl, long minT, long maxT) {
    TruthWave beliefs = this.beliefs;
    // if (!beliefs.isEmpty()) {
    renderTable(cc, minT, maxT, now, gl, beliefs, true);
    // }
    TruthWave goals = this.goals;
    // if (!goals.isEmpty()) {
    renderTable(cc, minT, maxT, now, gl, goals, false);
    if (showTaskLinks) {
        gl.glLineWidth(1f);
        float nowX = xTime(minT, maxT, now);
        cc.tasklinks().forEach(tl -> {
            if (tl != null) {
                Task x = tl.get(nar);
                if ((x != null) && (x.isBeliefOrGoal())) {
                    long o = x.start();
                    float tlx = o == ETERNAL ? nowX : xTime(minT, maxT, o);
                    if (tlx > 0 && tlx < 1) {
                        float tly = x.freq();
                        float ii = 0.3f + 0.7f * x.conf();
                        gl.glColor4f(ii / 2f, 0, ii, 0.5f + tl.pri() * 0.5f);
                        float w = 0.05f;
                        float h = 0.05f;
                        Draw.rectStroke(gl, tlx - w / 2, tly - h / 2, w, h);
                    }
                }
            }
        });
    }
// gl.glLineWidth(1f);
// gl.glColor4f(1f, 1f, 1f, 0.3f);
// Draw.strokeRect(gl, 0, 0, gew, geh);
// Draw.strokeRect(gl, gew, 0, tew, teh);
}
Also used : Task(nars.Task) TruthWave(nars.truth.TruthWave)

Example 39 with Task

use of nars.Task in project narchy by automenta.

the class NQuadsRDF method inputRaw.

public static Task inputRaw(@NotNull NAR nar, @Nullable Atom subject, @NotNull Atom predicate, @NotNull Term object) {
    if (subject == null)
        return null;
    if (predicatesIgnored.contains(predicate))
        return null;
    try {
        Term term = /*$.inst*/
        $.inh($.p(subject, object), predicate);
        if (term == null)
            throw new NullPointerException();
        Task t = new TaskBuilder(term, BELIEF, $.t(1f, nar.confDefault(BELIEF))).apply(nar);
        return t;
    } catch (Exception e) {
        logger.error("rdf({}) to task: {}", new Term[] { subject, object, predicate }, e);
        return null;
    }
}
Also used : TaskBuilder(nars.task.TaskBuilder) Task(nars.Task) Term(nars.term.Term)

Example 40 with Task

use of nars.Task in project narchy by automenta.

the class TasksView method layoutTimeline.

public void layoutTimeline() {
    final MapNodeGraph<Surface, String> graph = new MapNodeGraph();
    float tScale = 100;
    float tMin = tScale;
    for (Surface cc : children()) {
        // TODO make window content iteration method
        TaskIcon c = (TaskIcon) cc;
        Task t = c.task;
        NodeGraph.MutableNode<Surface, String> tn = graph.addNode(c);
        for (long e : t.stamp()) {
            NodeGraph.Node en = graph.node(evidences.getIfAbsentPutWithKey(e, (ee) -> {
                Surface s = new PushButton("_" + ee);
                // TODO make evidence buttons visibility toggleable
                // children.add(s);
                graph.addNode(s);
                return s;
            }));
            graph.addEdge((NodeGraph.MutableNode) en, "stamp", tn);
        }
        float minH = 30;
        float maxH = 200;
        float h = t.isQuestOrQuestion() ? Util.lerp(t.originality() / 2f, minH, maxH) : Util.lerp(t.originality() * t.conf(), minH, maxH);
        long start, end;
        if (!t.isEternal()) {
            start = t.start();
            end = t.end();
        } else {
            start = t.creation();
            // TODO max time
            end = 10;
        }
        float x1 = start * tScale;
        float x2 = end * tScale;
        if (x2 - x1 < tMin) {
            float x = (x1 + x2) / 2f;
            x1 = x - tMin / 2;
            x2 = x + tMin / 2;
        }
        float y = (float) (Math.random() * 500);
        c.pos(x1, y, x2, y + h);
    }
    graph.print();
    new Thread(() -> {
        int iterations = 300;
        for (int i = 0; i < iterations; i++) {
            layoutForceDirect(graph);
            layout();
            Util.sleep(5);
        }
    }).start();
}
Also used : NodeGraph(jcog.data.graph.NodeGraph) MutableContainer(spacegraph.space2d.container.MutableContainer) PushButton(spacegraph.space2d.widget.button.PushButton) Surface(spacegraph.space2d.Surface) IOException(java.io.IOException) MapNodeGraph(jcog.data.graph.MapNodeGraph) Util(jcog.Util) spacegraph.util.math.v2(spacegraph.util.math.v2) File(java.io.File) Task(nars.Task) TODO(jcog.TODO) Op(nars.Op) LongObjectHashMap(org.eclipse.collections.impl.map.mutable.primitive.LongObjectHashMap) SpaceGraph(spacegraph.SpaceGraph) Task(nars.Task) MapNodeGraph(jcog.data.graph.MapNodeGraph) NodeGraph(jcog.data.graph.NodeGraph) MapNodeGraph(jcog.data.graph.MapNodeGraph) Surface(spacegraph.space2d.Surface) PushButton(spacegraph.space2d.widget.button.PushButton)

Aggregations

Task (nars.Task)50 Term (nars.term.Term)15 NALTask (nars.task.NALTask)13 Truth (nars.truth.Truth)12 Nullable (org.jetbrains.annotations.Nullable)11 SignalTask (nars.task.signal.SignalTask)9 Test (org.junit.jupiter.api.Test)8 ITask (nars.task.ITask)6 FasterList (jcog.list.FasterList)5 NAR (nars.NAR)5 PreciseTruth (nars.truth.PreciseTruth)4 Util (jcog.Util)3 Top (jcog.sort.Top)3 Op (nars.Op)3 Param (nars.Param)3 TaskRegion (nars.task.util.TaskRegion)3 List (java.util.List)2 Map (java.util.Map)2 Random (java.util.Random)2 VLink (jcog.pri.VLink)2