use of nars.task.DebugDerivedTask in project narchy by automenta.
the class Taskify method test.
/**
* note: the return value here shouldnt matter so just return true anyway
*/
@Override
public boolean test(Derivation d) {
Truth tru = d.concTruth;
if (tru != null) {
float finalEvi = tru.evi() * d.concEviFactor;
if (d.eviMin > finalEvi) {
d.use(Param.TTL_EVI_INSUFFICIENT);
return true;
}
tru = tru.withEvi(finalEvi);
}
Term x0 = d.derivedTerm.get();
Term x = d.anon.get(x0).normalize();
long[] occ = d.concOcc;
byte punc = d.concPunc;
assert (punc != 0) : "no punctuation assigned";
DerivedTask t = (DerivedTask) Task.tryTask(x, punc, tru, (C, tr) -> {
int dither = d.ditherTime;
long start = Tense.dither(occ[0], dither);
long end = Tense.dither(occ[1], dither);
assert (end >= start) : "task has reversed occurrence: " + start + ".." + end;
return Param.DEBUG ? new DebugDerivedTask(C, punc, tr, start, end, d) : new DerivedTask(C, punc, tr, start, end, d);
});
if (t == null) {
d.nar.emotion.deriveFailTaskify.increment();
return spam(d, Param.TTL_DERIVE_TASK_FAIL);
}
if (same(t, d._task, d.freqRes) || (d._belief != null && same(t, d._belief, d.freqRes))) {
d.nar.emotion.deriveFailParentDuplicate.increment();
return spam(d, Param.TTL_DERIVE_TASK_SAME);
}
if (d.single)
t.setCyclic(true);
float priority = d.deriver.prioritize.pri(t, d);
if (priority != priority) {
d.nar.emotion.deriveFailPrioritize.increment();
return spam(d, Param.TTL_DERIVE_TASK_PRIORITIZE);
}
t.priSet(priority);
t.cause = ArrayUtils.addAll(d.parentCause, channel.id);
if (d.add(t) != t) {
d.nar.emotion.deriveFailDerivationDuplicate.increment();
spam(d, Param.TTL_DERIVE_TASK_REPEAT);
} else {
if (Param.DEBUG)
t.log(channel.ruleString);
d.use(Param.TTL_DERIVE_TASK_SUCCESS);
}
return true;
}
Aggregations