Search in sources :

Example 1 with Tasked

use of nars.task.Tasked in project narchy by automenta.

the class RTreeBeliefTable method add.

@Override
public boolean add(Task x, TaskConcept c, NAR n) {
    if (capacity() == 0)
        return false;
    float incoming = x.priElseZero();
    List<Tasked> added = new FasterList<>(2);
    write(treeRW -> {
        if (treeRW.add(x)) {
            if (!x.isDeleted()) {
                added.add(x);
                ensureCapacity(treeRW, x, added::add, n);
            }
        }
    });
    for (int i = 0, addedSize = added.size(); i < addedSize; i++) {
        Task y = added.get(i).task();
        if (y != null) {
            // completely activate a temporal task being stored in this table
            float pri = y.pri();
            if (pri == pri) {
                Tasklinks.linkTask(y, pri, c, n);
            }
        } else {
        // eternal task input already done by calling the .task() method. it willl have returned null
        }
    }
    if (x.isDeleted()) {
        Task xisting = x.meta("merge");
        if (xisting != null) {
            // use incoming priority but the existing task instance
            Tasklinks.linkTask(xisting, incoming, c, n);
        }
        return false;
    } else {
        return true;
    }
}
Also used : SignalTask(nars.task.signal.SignalTask) NALTask(nars.task.NALTask) Task(nars.Task) FasterList(jcog.list.FasterList) Tasked(nars.task.Tasked)

Example 2 with Tasked

use of nars.task.Tasked in project narchy by automenta.

the class TestNAR method mustEmit.

@NotNull
TestNAR mustEmit(@NotNull Topic<Tasked>[] c, long cycleStart, long cycleEnd, @NotNull String sentenceTerm, byte punc, float freqMin, float freqMax, float confMin, float confMax, LongPredicate start, LongPredicate end, boolean must) throws Narsese.NarseseException {
    if (freqMin == -1)
        freqMin = freqMax;
    int tt = temporalTolerance;
    cycleStart -= tt;
    cycleEnd += tt;
    float hf = freqTolerance / 2.0f;
    float hc = confTolerance / 2.0f;
    TaskCondition tc = new TaskCondition(nar, cycleStart, cycleEnd, sentenceTerm, punc, freqMin - hf, freqMax + hf, confMin - hc, confMax + hc, start, end);
    for (Topic<Tasked> cc : c) {
        cc.on(tc);
    }
    finished = false;
    if (must) {
        succeedsIfAll.add(tc);
    } else {
        // require entire execution, not just finish early
        exitOnAllSuccess = false;
        failsIfAny.add(tc);
    }
    return this;
// 
// ExplainableTask et = new ExplainableTask(tc);
// if (showExplanations) {
// explanations.add(et);
// }
// return et;
}
Also used : TaskCondition(nars.test.condition.TaskCondition) Tasked(nars.task.Tasked) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

Tasked (nars.task.Tasked)2 FasterList (jcog.list.FasterList)1 Task (nars.Task)1 NALTask (nars.task.NALTask)1 SignalTask (nars.task.signal.SignalTask)1 TaskCondition (nars.test.condition.TaskCondition)1 NotNull (org.jetbrains.annotations.NotNull)1