Search in sources :

Example 1 with SignalTask

use of nars.task.signal.SignalTask in project narchy by automenta.

the class Implier method taskify.

private void taskify(Map<LongObjectPair<Term>, TruthAccumulator> truths, byte punc, List<Task> gen) {
    float freqRes = nar.freqResolution.floatValue();
    float confRes = nar.confResolution.floatValue();
    float strength = this.strength.floatValue();
    float confMin = nar.confMin.floatValue();
    truths.forEach((tw, a) -> {
        Term t = tw.getTwo();
        long w = tw.getOne();
        long wEnd = w + dur;
        @Nullable Truth uu = a.commitSum().dither(freqRes, confRes, confMin, strength);
        long stamp = nar.time.nextStamp();
        NALTask y;
        if (uu != null && uu.conf() >= confMin) {
            y = new SignalTask(t, punc, uu, now, w, wEnd, stamp);
        } else {
            y = new SignalTask(t, punc == GOAL ? QUEST : QUESTION, null, now, w, wEnd, stamp);
        }
        y.pri(nar.priDefault(y.punc));
        // if (Param.DEBUG)
        // y.log("")
        // System.out.println("\t" + y);
        gen.add(y);
    });
}
Also used : NALTask(nars.task.NALTask) SignalTask(nars.task.signal.SignalTask) Term(nars.term.Term) Nullable(org.jetbrains.annotations.Nullable) Truth(nars.truth.Truth)

Example 2 with SignalTask

use of nars.task.signal.SignalTask in project narchy by automenta.

the class RLBooster method accept.

@Override
public void accept(NAR ignored) {
    // TODO provide actual action vector, not what it thinks it enacted by itself
    // NAgent's happiness value, normalized to -1..+1
    float reward = (env.happy.asFloat() - 0.5f) * 2f;
    int O = rl.act(reward, input());
    // System.out.println(now + " "  + o + " " + a.o.floatValue() + " " + " " + a.rewardValue);
    float OFFfreq = 0f;
    // = Float.NaN;
    NAR nar = env.nar();
    long start = env.last;
    long end = env.now;
    // int dur = nar.dur();
    List<Task> e = new FasterList(actions.length);
    for (int o = 0; o < actions.length; o++) {
        Truth off = OFFfreq == OFFfreq ? $.t(OFFfreq, conf.floatValue()) : null;
        // float value = actionDiscretization==1 ? 1f /* full */ :
        // ((float)(j)) / (actionDiscretization-1);
        float value = 1f;
        Truth tK;
        if (o == O) {
            tK = $.t(value, conf.floatValue());
        } else {
            // cancel all other concept goal signals
            tK = off;
        }
        Task tt = new SignalTask(actions[o].term(), GOAL, tK, start, start, end, nar.time.nextStamp());
        if (tt != null)
            e.add(tt);
    }
    in.input(e);
}
Also used : SignalTask(nars.task.signal.SignalTask) ITask(nars.task.ITask) Task(nars.Task) FasterList(jcog.list.FasterList) SignalTask(nars.task.signal.SignalTask) NAR(nars.NAR) Truth(nars.truth.Truth)

Example 3 with SignalTask

use of nars.task.signal.SignalTask in project narchy by automenta.

the class RTreeBeliefTable method eternalize.

private void eternalize(Task x, Consumer<Tasked> added, NAR nar) {
    if ((x instanceof SignalTask)) {
        // ignore for now
        return;
    }
    float xPri = x.pri();
    if (xPri != xPri)
        // deleted already somehow
        return;
    float xc = x.conf();
    float e = x.eviEternalized((1 / xc) * size());
    float c = w2cSafe(e);
    if (c >= nar.confMin.floatValue()) {
        added.accept(() -> {
            // if (x.op().temporal) { //==IMPL /*x.op().statement */ /*&& !x.term().isTemporal()*/) {
            // //experimental eternalize
            Task eternalized = Task.clone(x, x.term(), Truth.theDithered(x.freq(), e, nar), x.punc(), x.creation(), ETERNAL, ETERNAL);
            if (eternalized != null) {
                eternalized.pri(xPri * c / xc);
                if (Param.DEBUG)
                    eternalized.log("Eternalized Temporal");
                nar.input(eternalized);
                if (!(eternalized.isDeleted()))
                    ((NALTask) x).delete(eternalized);
            }
            return null;
        });
    }
}
Also used : SignalTask(nars.task.signal.SignalTask) NALTask(nars.task.NALTask) Task(nars.Task) SignalTask(nars.task.signal.SignalTask)

Example 4 with SignalTask

use of nars.task.signal.SignalTask in project narchy by automenta.

the class GoalActionAsyncConcept method feedback.

public void feedback(@Nullable Truth f, @Nullable Truth g, NAR nar) {
    long now = nar.time();
    int dur = nar.dur();
    // long start =
    // now - dur/2;
    // long end =
    // now + dur/2;
    long start = now;
    long end = now + dur;
    Task fg;
    if (g != null) {
        // //fg = feedGoal.task(term, g, goalTime-dur, goalTime, nar.time.nextStamp()); //allow the feedback goal (Ex: curiosity) to override, otherwise use the current goal
        // fg = feedGoal.set(this, g, stamper, goalTime, dur, nar);
        // fg = GoalActionConcept.curiosity(nar, g, term, curiosityStamp);
        fg = null;
    } else
        fg = null;
    SignalTask fb = ((ScalarBeliefTable) beliefs()).add(f, start, end, dur, nar);
    in.input(fg, fb);
    PredictionFeedback.feedbackSignal(fb, /* in case stretched */
    beliefs, nar);
}
Also used : SignalTask(nars.task.signal.SignalTask) ITask(nars.task.ITask) Task(nars.Task) SignalTask(nars.task.signal.SignalTask) ScalarBeliefTable(nars.concept.dynamic.ScalarBeliefTable)

Example 5 with SignalTask

use of nars.task.signal.SignalTask in project narchy by automenta.

the class ScalarBeliefTable method add.

public SignalTask add(Truth value, long start, long end, int dur, NAR nar) {
    value = value.ditherFreq(Math.max(nar.freqResolution.asFloat(), res.asFloat()));
    SignalTask x = series.add(term, punc(), start, end, value, dur, nar);
    if (x != null)
        x.pri(pri.asFloat());
    PredictionFeedback.feedbackSignal(x, this, nar);
    return x;
}
Also used : SignalTask(nars.task.signal.SignalTask)

Aggregations

SignalTask (nars.task.signal.SignalTask)6 Task (nars.Task)3 ITask (nars.task.ITask)2 NALTask (nars.task.NALTask)2 Truth (nars.truth.Truth)2 FasterList (jcog.list.FasterList)1 NAR (nars.NAR)1 ScalarBeliefTable (nars.concept.dynamic.ScalarBeliefTable)1 Term (nars.term.Term)1 Nullable (org.jetbrains.annotations.Nullable)1