use of nars.NAgent in project narchy by automenta.
the class ExeCharts method metaGoalChart.
private static Surface metaGoalChart(NAgent a) {
return new TreeChart<Cause>() {
final DurService on;
final FasterList<ItemVis<Cause>> cache = new FasterList();
final Function<Cause, TreeChart.ItemVis<Cause>> builder = ((i) -> {
short id = i.id;
ItemVis<Cause> item;
if (cache.capacity() - 1 < id)
cache.ensureCapacity(id + 16);
else {
item = cache.get(id);
if (item != null)
return item;
}
String str = i.toString();
if (str.startsWith("class nars."))
// skip default toString
str = str.substring("class nars.".length());
if (str.startsWith("class "))
// skip default toString
str = str.substring(5);
item = new CauseVis(i, str);
cache.set(id, item);
return item;
});
{
on = a.onFrame(() -> {
update(a.nar().causes, (c, i) -> {
float v = c.value();
float r, g, b;
if (v < 0) {
r = 0.75f * Math.max(0.1f, Math.min(1f, -v));
g = 0;
} else {
g = 0.75f * Math.max(0.1f, Math.min(1f, +v));
r = 0;
}
float t = Util.sum(((FloatFunction<Traffic>) (p -> Math.abs(p.last))), c.goal);
b = Math.max(r, g) / 2f * Util.unitize(t);
i.update(v, r, g, b);
// i.updateMomentum(
// //0.01f + Util.sqr(Util.tanhFast(v)+1),
// //Math.signum(v) *(1+Math.abs(v))*(t),
// //Math.signum(v) * t,
// v,
// 0.25f,
// r, g, b);
}, builder);
});
}
@Override
public void stop() {
super.stop();
on.off();
}
};
}
use of nars.NAgent in project narchy by automenta.
the class PoleCart method main.
// private final ScalarConcepts dAngVel;
public static void main(String[] arg) {
runRT((n) -> {
try {
NAgent a = new PoleCart(n);
a.nar().freqResolution.set(0.02f);
a.nar().confResolution.set(0.02f);
NARSpeak s = new NARSpeak(n);
s.speech.chatty();
s.spoken.on(new NativeSpeechDispatcher()::speak);
// n.goalConfidence(0.75f);
return a;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}, 30, 10f);
}
Aggregations