use of nars.NAR in project narchy by automenta.
the class QuerySpider method starting.
@Override
protected void starting(NAR nar) {
nar.onTask(t -> {
if (t.isQuestOrQuestion() && t.term().hasVarQuery()) {
Term tt = t.term();
AdjGraph<Term, Float> g = spider(nar, t, 3);
g.nodes.keysView().takeWhile(r -> {
new UnifySubst(null, nar, (z) -> {
// TODO
return true;
}, Param.TTL_MIN()).unify(tt, r.v, true);
return true;
});
}
});
}
use of nars.NAR 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.NAR in project narchy by automenta.
the class TaskBudgetingTest method structuralDeduction1.
/**
* taskbudgeting - structural deduction test
* decompose large conj, analyze the durability, quality decay
*/
@Test
public void structuralDeduction1() throws Narsese.NarseseException {
NAR d = NARS.tmp();
d.log();
d.believe("(&&, (a),(b),(c),(d),(e) )");
d.run(100);
}
use of nars.NAR in project narchy by automenta.
the class ScalarBeliefTableTest method test1.
@Test
public void test1() {
NAR n = NARS.shell();
MutableFloat xx = new MutableFloat(0);
Scalar x = new Scalar($.the("x"), xx, n);
DurService xAuto = x.auto(n, 1);
ScalarBeliefTable xb = (ScalarBeliefTable) x.beliefs();
n.synch();
n.run(1);
assertEquals(1, xb.series.size());
assertEquals(1, xb.size());
xx.set(0.5f);
n.run(1);
assertEquals(2, xb.series.size());
assertEquals(2, xb.size());
}
use of nars.NAR in project narchy by automenta.
the class BasicRulesTest method testSubstitution2.
@Test
public void testSubstitution2() throws Narsese.NarseseException {
// (($1 --> M) ==> C), (S --> M), substitute($1,S) |- C, (Truth:Deduction, Order:ForAllSame)
NAR n = NARS.shell();
n.input("<<$1 --> happy> ==> <$1--> dead>>. <S --> happy>.");
// <<$1 --> drunk> ==> <$1--> dead>>. <S --> drunk>. |- <S --> dead>.
// OUT: <S --> dead>. %1.00;0.81% {58: 1;2}
// TextOutput.out(n);
n.run(150);
}
Aggregations