use of nars.time.Tense.XTERNAL in project narchy by automenta.
the class DynamicTruthBeliefTable method matchDT.
/**
* returns an appropriate dt for the root term
* of beliefs held in the table. returns 0 if no other value can
* be computed.
*/
protected int matchDT(long start, long end, boolean commutive, NAR nar) {
int s = size();
if (s == 0)
return 0;
int dur = nar.dur();
IntFloatHashMap dtEvi = new IntFloatHashMap(s);
forEachTask(t -> {
int tdt = t.dt();
if (tdt != DTERNAL) {
if (tdt == XTERNAL)
throw new RuntimeException("XTERNAL should not be present in " + t);
if ((t.term().subs() > 2) == commutive)
// maybe evi
dtEvi.addToValue(tdt, t.evi(start, end, dur));
}
});
int n = dtEvi.size();
if (n == 0) {
return 0;
} else {
MutableList<IntFloatPair> ll = dtEvi.keyValuesView().toList();
int selected = n != 1 ? Roulette.decideRoulette(ll.size(), (i) -> ll.get(i).getTwo(), nar.random()) : 0;
return ll.get(selected).getOne();
}
}
Aggregations