use of nars.NAR in project narchy by automenta.
the class ImplicationNetworkTest method testEternal_A_PosGoal_ToBC.
@Test
public void testEternal_A_PosGoal_ToBC() {
NAR n = NARS.tmp();
Param.DEBUG = true;
n.believe(IMPL.the(a, b));
n.believe(IMPL.the(b, c));
n.goal(a);
n.run(100);
BeliefTable aGoals = n.concept(a).goals();
Truth aGoal = aGoals.truth(ETERNAL, n);
// n.concept(a).print();
// a belief state should not exceed the input (default confidence) and freq remain stable
// additional beliefs are not helpful
assertEquals(1, aGoals.size());
BeliefTable bGoals = n.concept(b).goals();
Truth bGoal = bGoals.truth(ETERNAL, n);
n.concept(b).print();
assertEquals(1, bGoals.size());
// b should have less conf than a but higher than c
// same freq among all
BeliefTable cGoals = n.concept(c).goals();
Truth cGoal = cGoals.truth(ETERNAL, n);
n.concept(c).print();
// assertEquals(1, cGoals.size());
System.out.println("a: " + aGoal);
System.out.println("b: " + bGoal);
System.out.println("c: " + cGoal);
assertEquals(aGoal.freq(), bGoal.freq(), n.freqResolution.floatValue());
assertEquals(bGoal.freq(), cGoal.freq(), n.freqResolution.floatValue());
assertTrue(aGoal.conf() - bGoal.conf() > n.confResolution.floatValue() * 2);
assertTrue(bGoal.conf() - cGoal.conf() > n.confResolution.floatValue() * 2);
}
use of nars.NAR in project narchy by automenta.
the class LinkageTest method Variable_Normalization_1.
// @Test
// public void Advanced_Concept_Formation_Test4() throws Exception {
// testConceptFormed("(&&,<#1 --> (/,open,#2,_)>,<#1 --> lock>,<#2 --> key>)");
// }
@Test
public void Variable_Normalization_1() throws Exception {
// this.activeTasks = activeTasks;
NAR tester = NARS.tmp();
test.requireConditions = false;
String nonsense = "<(&&,<#1 --> M>,<#2 --> M>) ==> <#1 --> nonsense>>";
// .en("If robin is a type of bird then robin can fly.");
tester.believe(nonsense);
tester.run(1);
Concept c = tester.conceptualize(nonsense);
assertNotNull(c);
}
use of nars.NAR in project narchy by automenta.
the class STRIPSTest method testBanana1.
@Test
public void testBanana1() throws Narsese.NarseseException {
NAR n = new NARS().tmp();
n.log();
n.input("At(A). :|:", "Level(low). :|:", "BoxAt(C). :|:", "BananasAt(B). :|:", /* Goal state: Eat(bananas) */
"Eat(bananas)!", // _Move(X, Y)_
"((At($X) &&+0 Level(low)) ==>+1 (--At($X) &&+0 At(#Y))).", // _ClimbUp(Location)_ climb up the box
"(((At(#Location) &&+0 BoxAt(#Location)) &&+0 Level(low)) ==>+1 (Level(high) &&+0 --Level(low))).", // _ClimbDown(Location)_ climb down from the box
"(((At(#Location) &&+0 BoxAt(#Location)) &&+0 Level(high)) ==>+1 (Level(low), --Level(high))).", /* Preconditions: At(X), BoxAt(X), Level(low)
Postconditions: BoxAt(Y), not BoxAt(X), At(Y), not At(X) */
"(((At($X) &&+0 BoxAt($X)) &&+0 Level(low)) ==>+1 ((((At(#Y) &&+0 BoxAt(#Y)) &&+0 --BoxAt($X)) &&+0 --At($X)))).", /* Preconditions: At(Location), BananasAt(Location), Level(high)
Postconditions: Eat(bananas) */
"(((At(#Location) &&+0 BananasAt(#Location)) &&+0 Level(high)) ==>+1 Eat(bananas)).");
n.run(1000);
}
use of nars.NAR in project narchy by automenta.
the class ListFuncTest method testTestResult.
@Test
public void testTestResult() {
NAR n = NARS.shell();
assertEquals(Set.of($$("append((x),(y),(x,y))")), Solution.solve($$("append((x),(y),(x,y))"), n.concepts.functors));
assertEquals(Set.of($$("append(x,y,(x,y))")), Solution.solve($$("append(x,y,(x,y))"), n.concepts.functors));
assertEquals(Set.of(False), Solution.solve($$("append((x),(y),(x,y,z))"), n.concepts.functors));
}
use of nars.NAR in project narchy by automenta.
the class ListFuncTest method testAppendHeadAndTail.
@Test
public void testAppendHeadAndTail() {
NAR n = NARS.shell();
assertEquals(Set.of($$("append((x,y,z),(),(x,y,z))"), $$("append((x,y),(z),(x,y,z))"), $$("append((x),(y,z),(x,y,z))"), $$("append((),(x,y,z),(x,y,z))")), Solution.solve($$("append(#x,#y,(x,y,z))"), n.concepts.functors));
}
Aggregations