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);
});
}
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);
}
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;
});
}
}
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);
}
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;
}
Aggregations