use of nars.Task in project narchy by automenta.
the class NarseseBaseTest method testNoBudget.
@Test
public void testNoBudget() throws Narsese.NarseseException {
Task t = task("<a ==> b>. %0.00;0.93");
assertNotNull(t);
assertEquals(Op.IMPL, t.op());
assertEquals('.', t.punc());
// assertEquals(Global.DEFAULT_JUDGMENT_PRIORITY, t.getPriority(), 0.001);
// assertEquals(Global.DEFAULT_JUDGMENT_DURABILITY, t.getDurability(), 0.001);
assertEquals(0.0f, t.freq(), 0.001);
assertEquals(0.93f, t.conf(), 0.001);
}
use of nars.Task in project narchy by automenta.
the class NarseseBaseTest method testQuest.
@Test
public void testQuest() throws Narsese.NarseseException {
String tt = "(a,b,c)";
Task t = task(tt + '@');
assertNotNull(t);
assertEquals(PROD, t.op());
assertEquals(tt, t.term().toString());
assertEquals('@', t.punc());
assertNull(t.truth());
}
use of nars.Task in project narchy by automenta.
the class BeliefTableChart method draw.
protected void draw(Termed tt, Concept cc, GL2 gl, long minT, long maxT) {
TruthWave beliefs = this.beliefs;
// if (!beliefs.isEmpty()) {
renderTable(cc, minT, maxT, now, gl, beliefs, true);
// }
TruthWave goals = this.goals;
// if (!goals.isEmpty()) {
renderTable(cc, minT, maxT, now, gl, goals, false);
if (showTaskLinks) {
gl.glLineWidth(1f);
float nowX = xTime(minT, maxT, now);
cc.tasklinks().forEach(tl -> {
if (tl != null) {
Task x = tl.get(nar);
if ((x != null) && (x.isBeliefOrGoal())) {
long o = x.start();
float tlx = o == ETERNAL ? nowX : xTime(minT, maxT, o);
if (tlx > 0 && tlx < 1) {
float tly = x.freq();
float ii = 0.3f + 0.7f * x.conf();
gl.glColor4f(ii / 2f, 0, ii, 0.5f + tl.pri() * 0.5f);
float w = 0.05f;
float h = 0.05f;
Draw.rectStroke(gl, tlx - w / 2, tly - h / 2, w, h);
}
}
}
});
}
// gl.glLineWidth(1f);
// gl.glColor4f(1f, 1f, 1f, 0.3f);
// Draw.strokeRect(gl, 0, 0, gew, geh);
// Draw.strokeRect(gl, gew, 0, tew, teh);
}
use of nars.Task in project narchy by automenta.
the class NQuadsRDF method inputRaw.
public static Task inputRaw(@NotNull NAR nar, @Nullable Atom subject, @NotNull Atom predicate, @NotNull Term object) {
if (subject == null)
return null;
if (predicatesIgnored.contains(predicate))
return null;
try {
Term term = /*$.inst*/
$.inh($.p(subject, object), predicate);
if (term == null)
throw new NullPointerException();
Task t = new TaskBuilder(term, BELIEF, $.t(1f, nar.confDefault(BELIEF))).apply(nar);
return t;
} catch (Exception e) {
logger.error("rdf({}) to task: {}", new Term[] { subject, object, predicate }, e);
return null;
}
}
use of nars.Task in project narchy by automenta.
the class TasksView method layoutTimeline.
public void layoutTimeline() {
final MapNodeGraph<Surface, String> graph = new MapNodeGraph();
float tScale = 100;
float tMin = tScale;
for (Surface cc : children()) {
// TODO make window content iteration method
TaskIcon c = (TaskIcon) cc;
Task t = c.task;
NodeGraph.MutableNode<Surface, String> tn = graph.addNode(c);
for (long e : t.stamp()) {
NodeGraph.Node en = graph.node(evidences.getIfAbsentPutWithKey(e, (ee) -> {
Surface s = new PushButton("_" + ee);
// TODO make evidence buttons visibility toggleable
// children.add(s);
graph.addNode(s);
return s;
}));
graph.addEdge((NodeGraph.MutableNode) en, "stamp", tn);
}
float minH = 30;
float maxH = 200;
float h = t.isQuestOrQuestion() ? Util.lerp(t.originality() / 2f, minH, maxH) : Util.lerp(t.originality() * t.conf(), minH, maxH);
long start, end;
if (!t.isEternal()) {
start = t.start();
end = t.end();
} else {
start = t.creation();
// TODO max time
end = 10;
}
float x1 = start * tScale;
float x2 = end * tScale;
if (x2 - x1 < tMin) {
float x = (x1 + x2) / 2f;
x1 = x - tMin / 2;
x2 = x + tMin / 2;
}
float y = (float) (Math.random() * 500);
c.pos(x1, y, x2, y + h);
}
graph.print();
new Thread(() -> {
int iterations = 300;
for (int i = 0; i < iterations; i++) {
layoutForceDirect(graph);
layout();
Util.sleep(5);
}
}).start();
}
Aggregations