use of nars.NAR in project narchy by automenta.
the class TrieDeriverTest method test.
public TestNAR test(int tlMax, boolean debug, String... rules) {
NAR n = new NARS().deriverAddRules(rules).get();
TestNAR t = new TestNAR(n);
tests.add(t);
return t;
}
use of nars.NAR in project narchy by automenta.
the class PatrickTests method testConditioningWithoutAnticipation.
/**
* TODO
*/
@Disabled
@Test
public void testConditioningWithoutAnticipation() throws Narsese.NarseseException {
/*
<a --> A>. :|: <b --> B>. :|: %0% <c --> C>. %0%
8
<b --> B>. :|: <a --> A>. :|: %0% <c --> C>. %0%
8
<c --> C>. :|: <a --> a>. :|: %0% <b --> B>. %0%
8
<a --> A>. :|: <b --> B>. :|: %0% <c --> C>. %0%
100
<b --> B>. :|: <a --> A>. :|: %0% <c --> C>. %0%
100
<?1 =/> <c --> C>>? //this line needs to be translated to NARchy syntax
Expected result: (also in OpenNARS syntax)
For appropriate Interval term "time", "time2",
<(&/,<a --> A>,time) =/> <c --> C>>.
and
<(&/,<b --> B>,time) =/> <c --> C>>.
needs to be reduced in frequency, making
<(&/,<a --> A>,time,<b --> B>,time2) =/> <c --> C>>.
the strongest hypothesis based on the last two inputs where neither a nor b "leaded to" c.
*/
NAR n = NARS.tmp();
n.beliefPriDefault.set(0.01f);
n.termVolumeMax.set(16);
// n.log();
n.inputAt(0, " A:a. :|: --B:b. :|: --C:c. :|:");
n.inputAt(8, " B:b. :|: --A:a. :|: --C:c. :|:");
n.inputAt(16, " C:c. :|: --A:a. :|: --B:b. :|:");
n.inputAt(24, " A:a. :|: --B:b. :|: --C:c. :|:");
n.inputAt(124, " B:b. :|: --A:a. :|: --C:c. :|:");
n.run(224);
n.clear();
n.input(" $0.9 (?x ==> C:c)?");
// n.input(" $0.9;0.9$ (?x ==>+8 C:c)?");
// n.input(" $0.9;0.9$ ((A:a && B:b) ==> C:c)?");
// n.input(" $0.9;0.9$ ((A:a && B:b) ==> C:c)? :|:");
n.run(2000);
/*
Expected result: (also in OpenNARS syntax)
For appropriate Interval term "time", "time2",
<(&/,<a --> A>,time) =/> <c --> C>>.
and
<(&/,<b --> B>,time) =/> <c --> C>>.
needs to be reduced in frequency, making
<(&/,<a --> A>,time,<b --> B>,time2) =/> <c --> C>>.
the strongest hypothesis based on the last two inputs where neither a nor b "leaded to" c.
*/
}
use of nars.NAR in project narchy by automenta.
the class PatrickTests method testPixelImage.
/**
* TODO
*/
@Test
@Disabled
public void testPixelImage() throws Narsese.NarseseException {
// this.activeTasks = activeTasks;
NAR n = NARS.tmp();
// n.log();
// n.truthResolution.setValue(0.05f);
n.termVolumeMax.set(60);
n.beliefPriDefault.set(0.05f);
n.questionPriDefault.set(0.9f);
// assume that unless pixel isnt specified then it's black
n.input("<#x --> P>. %0.0;0.25%");
// to what extent was
// | |
// | ██ |
// | ██████ |
// | ██ |
// | |
// observed in experience?
// imperfectly observed pattern
// | ░░ |
// | ▓▓ |
// |░░▓▓██ |
// | ▒▒ ░░|
// | ░░ |
String image1 = "<p_1_1 --> P>. :|: %0.5;0.9%\n" + "<p_1_2 --> P>. :|: %0.5;0.9%\n" + "<p_1_3 --> P>. :|: %0.6;0.9%\n" + "<p_1_4 --> P>. :|: %0.6;0.9%\n" + "<p_1_5 --> P>. :|: %0.5;0.9%\n" + "<p_2_1 --> P>. :|: %0.5;0.9%\n" + "<p_2_2 --> P>. :|: %0.5;0.9%\n" + "<p_2_3 --> P>. :|: %0.8;0.9%\n" + "<p_2_4 --> P>. :|: %0.5;0.9%\n" + "<p_2_5 --> P>. :|: %0.5;0.9%\n" + "<p_3_1 --> P>. :|: %0.6;0.9%\n" + "<p_3_2 --> P>. :|: %0.8;0.9%\n" + "<p_3_3 --> P>. :|: %0.9;0.9%\n" + "<p_3_4 --> P>. :|: %0.5;0.9%\n" + "<p_3_5 --> P>. :|: %0.5;0.9%\n" + "<p_4_1 --> P>. :|: %0.5;0.9%\n" + "<p_4_2 --> P>. :|: %0.5;0.9%\n" + "<p_4_3 --> P>. :|: %0.7;0.9%\n" + "<p_5_4 --> P>. :|: %0.6;0.9%\n" + "<p_4_4 --> P>. :|: %0.5;0.9%\n" + "<p_4_5 --> P>. :|: %0.6;0.9%\n" + "<p_5_1 --> P>. :|: %0.5;0.9%\n" + "<p_5_2 --> P>. :|: %0.5;0.9%\n" + "<p_5_3 --> P>. :|: %0.5;0.9%\n" + "<p_5_5 --> P>. :|: %0.5;0.9%\n" + "<example1 --> name>. :|:";
n.input(image1.split("\n"));
// (&|,<p_2_3 --> pixel>,<p_3_2 --> pixel>,<p_3_3 --> pixel>,<p_3_4 --> pixel>,<p_4_3 --> pixel>,<example1 --> name>)?\n" +
// for (int i = 0; i < 2; i++) {
n.question($.parallel($("P:p_2_3"), $("P:p_3_2"), $("P:p_3_4"), $("P:p_4_3"), $("name:example1")));
// }
// Answer (&|,<example1 --> name>,<p_2_3 --> pixel>,<p_3_2 --> pixel>,<p_3_3 --> pixel>,<p_3_4 --> pixel>,<p_4_3 --> pixel>). :-1: %0.80;0.16%
// ex: (&&,(example1-->name),(p_2_3-->pixel),(p_3_2-->pixel),(p_3_4-->pixel),(p_4_3-->pixel)). %.61;.06%"".
n.run(6000);
n.clear();
// imperfectly observed pattern
// | ░░ |
// | ▓▓ |
// |░░ ▓▓ |
// | ▒▒ ░░|
// | ░░ |
String image2 = "<p_1_1 --> pixel>. :|: %0.5;0.9%\n" + "<p_1_2 --> pixel>. :|: %0.5;0.9%\n" + "<p_1_3 --> pixel>. :|: %0.6;0.9%\n" + "<p_1_4 --> pixel>. :|: %0.6;0.9%\n" + "<p_1_5 --> pixel>. :|: %0.5;0.9%\n" + "<p_2_1 --> pixel>. :|: %0.5;0.9%\n" + "<p_2_2 --> pixel>. :|: %0.5;0.9%\n" + "<p_2_3 --> pixel>. :|: %0.8;0.9%\n" + "<p_2_4 --> pixel>. :|: %0.5;0.9%\n" + "<p_2_5 --> pixel>. :|: %0.5;0.9%\n" + "<p_3_1 --> pixel>. :|: %0.6;0.9%\n" + "<p_3_2 --> pixel>. :|: %0.5;0.9%\n" + "<p_3_3 --> pixel>. :|: %0.5;0.9%\n" + "<p_3_4 --> pixel>. :|: %0.8;0.9%\n" + "<p_3_5 --> pixel>. :|: %0.5;0.9%\n" + "<p_4_1 --> pixel>. :|: %0.5;0.9%\n" + "<p_4_2 --> pixel>. :|: %0.5;0.9%\n" + "<p_4_3 --> pixel>. :|: %0.7;0.9%\n" + "<p_5_4 --> pixel>. :|: %0.6;0.9%\n" + "<p_4_4 --> pixel>. :|: %0.5;0.9%\n" + "<p_4_5 --> pixel>. :|: %0.6;0.9%\n" + "<p_5_1 --> pixel>. :|: %0.5;0.9%\n" + "<p_5_2 --> pixel>. :|: %0.5;0.9%\n" + "<p_5_3 --> pixel>. :|: %0.5;0.9%\n" + "<p_5_5 --> pixel>. :|: %0.5;0.9%\n" + "<example2 --> name>. :|:";
n.input(image2.split("\n"));
// (&|,<p_2_3 --> pixel>,<p_3_2 --> pixel>,<p_3_3 --> pixel>,<p_3_4 --> pixel>,<p_4_3 --> pixel>,<example2 --> name>)?
// for (int i = 0; i < 8; i++) {
n.question($.parallel($("P:p_2_3"), $("P:p_3_2"), $("P:p_3_3"), $("P:p_3_4"), $("P:p_4_3"), $("name:example2")));
n.run(6000);
// }
// Answer (&|,<example2 --> name>,<p_2_3 --> pixel>,<p_3_2 --> pixel>,<p_3_3 --> pixel>,<p_3_4 --> pixel>,<p_4_3 --> pixel>). %0.50;0.40%
}
use of nars.NAR in project narchy by automenta.
the class NAL1MultistepTest method nar.
@Override
protected NAR nar() {
NAR n = NARS.tmp(6);
n.termVolumeMax.set(6);
n.freqResolution.set(0.2f);
n.confResolution.set(0.1f);
return n;
}
use of nars.NAR in project narchy by automenta.
the class NARServiceTest method testRemoveDurServiceWhenOff.
@Test
public void testRemoveDurServiceWhenOff() {
NAR n = NARS.shell();
Set<Service<NAR>> before = n.services.stream().collect(toSet());
DurService d = DurService.on(n, () -> {
// nothing
});
n.synch();
Set<Service<NAR>> during = n.services.stream().collect(toSet());
d.off();
n.synch();
Set<Service<NAR>> after = n.services.stream().collect(toSet());
assertEquals(before, after);
assertEquals(before.size() + 1, during.size());
}
Aggregations