use of org.eclipse.collections.api.block.function.primitive.FloatFloatToObjectFunction in project narchy by automenta.
the class NAgent method run.
@Override
public void run() {
if (!enabled.get())
return;
this.last = this.now;
this.now = nar.time();
if (now <= last)
return;
// stretched perceptual duration to the NAgent's effective framerate
int dur = Math.max(nar.dur(), (int) (now - last));
reward = act();
happy.update(last, now, dur, nar);
FloatFloatToObjectFunction<Truth> truther = (prev, next) -> $.t(next, nar.confDefault(BELIEF));
sensors.forEach((key, value) -> value.input(key.update(last, now, truther, dur, nar)));
always(motivation.floatValue());
// HACK TODO compile this to re-used array on init like before
Map.Entry<ActionConcept, CauseChannel<ITask>>[] aa = actions.entrySet().toArray(new Map.Entry[actions.size()]);
// fair chance of ordering to all motors
ArrayUtils.shuffle(aa, random());
for (Map.Entry<ActionConcept, CauseChannel<ITask>> ac : aa) {
Stream<ITask> s = ac.getKey().update(last, now, dur, NAgent.this.nar);
if (s != null)
ac.getValue().input(s);
}
Truth happynowT = nar.beliefTruth(happy, last, now);
float happynow = happynowT != null ? (happynowT.freq() - 0.5f) * 2f : 0;
nar.emotion.happy(motivation.floatValue() * dexterity(last, now) * happynow);
if (trace)
logger.info(summary());
}
Aggregations