Search in sources :

Example 46 with NAR

use of nars.NAR in project narchy by automenta.

the class TestProloglike method testRiddle1.

@Test
public void testRiddle1() throws Exception {
    // Param.DEBUG = true;
    NAR n = NARS.tmp();
    n.termVolumeMax.set(1024);
    n.log();
    n.inputNarsese(TestProloglike.class.getResource("einsteinsRiddle.nal"));
    n.run(128);
}
Also used : NAR(nars.NAR) Test(org.junit.jupiter.api.Test)

Example 47 with NAR

use of nars.NAR in project narchy by automenta.

the class TermTreeTest method testCompoundInsertion.

@Test
public void testCompoundInsertion() throws Narsese.NarseseException {
    TreeConceptIndex index;
    NAR nar = new NARS().index(index = new TreeConceptIndex(1000)).get();
    int preSize = index.size();
    String[] terms = { "x", "(x)", "(xx)", "(xxx)", "(x,y)", "(x,z)", "(x --> z)", "(x <-> z)", "(x&&z)" };
    HashSet<Term> input = new HashSet();
    for (String s : terms) {
        @NotNull Term ts = $(s);
        input.add(ts);
        index.get(ts, true);
    }
    assertEquals(terms.length + preSize, index.size());
    for (Term x : input) assertNotNull(index.get(x, false));
    // Set<Termed> stored = StreamSupport.stream(index.concepts.spliterator(), false).collect(Collectors.toSet());
    // assertEquals(Sets.symmetricDifference(input, stored) + " = difference", input, stored);
    index.concepts.prettyPrint();
    index.print(System.out);
// String stringWithUnicode = "unicode\u00easomething";
// assertNull( tree.resolveOrAdd(stringWithUnicode)); //unicode not supported yet
}
Also used : NARS(nars.NARS) TreeConceptIndex(nars.index.term.TreeConceptIndex) NotNull(org.jetbrains.annotations.NotNull) NAR(nars.NAR) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 48 with NAR

use of nars.NAR in project narchy by automenta.

the class JsonTermTest method testBigJSON2.

@Test
public void testBigJSON2() {
    /*
        * https://eonet.sci.gsfc.nasa.gov/api/v2.1/events?limit=5&days=20&source=InciWeb&status=open
        * https://worldview.earthdata.nasa.gov/config/wv.json
        * */
    String j = "{ \"id\": \"EONET_2797\",\n" + "   \"title\": \"Snake Ridge Fire, ARIZONA\",\n" + "   \"description\": \"\",\n" + "   \"link\": \"http://eonet.sci.gsfc.nasa.gov/api/v2.1/events/EONET_2797\",\n" + "   \"categories\": [\n" + "    {\n" + "     \"id\": 8,\n" + "     \"title\": \"Wildfires\"\n" + "    }\n" + "   ] }";
    NAR d = new NARS().get();
    d.log();
    d.believe($.inh($.fromJSON(j), "x"));
    d.run(1000);
}
Also used : NARS(nars.NARS) NAR(nars.NAR) Test(org.junit.jupiter.api.Test)

Example 49 with NAR

use of nars.NAR in project narchy by automenta.

the class JsonTermTest method testJsonArray.

@Test
public void testJsonArray() throws Narsese.NarseseException {
    NAR d = new NARS().get();
    d.log();
    new TaskRule("(json,%1):{x(%2)}", "X(%1,%2)", d);
    // d.believe( $.inh( JsonCompound.the("['a', 1, ['b', 'c']]"), $.the("(json,1)")  ) );
    // TaskProcess: $.50;.95$ (("a"),(1),(("b"),("c"))). %1.0;.90% {0: 1}
    d.believe($.inh(JsonTerm.the("{ x: 3, y: [\"a\",4] }"), $.$("(json,2)")));
    // d.believe( $.inh( JsonCompound.the("{ x: 3 }"), $.$("(json,2)") ) );
    // $.15;.86$ X(3,2). %1.0;.81% {1: 1;;}
    // $.50;.95$ {x(3),y(("a"),("b"))}. %1.0;.90% {0: 2}
    d.run(256);
}
Also used : NARS(nars.NARS) TaskRule(nars.task.util.TaskRule) NAR(nars.NAR) Test(org.junit.jupiter.api.Test)

Example 50 with NAR

use of nars.NAR in project narchy by automenta.

the class SomeRovers method main.

public static void main(String[] args) {
    Global.DEBUG = Global.EXIT_ON_EXCEPTION = false;
    float fps = 60;
    boolean cpanels = true;
    RoverWorld world;
    // world = new ReactorWorld(this, 32, 48, 48*2);
    world = new FoodSpawnWorld1(128, 48, 48, 0.5f);
    // world = new GridSpaceWorld(GridSpaceWorld.newMazePlanet());
    final Sim game = new Sim(clock, world);
    game.add(new Turret("turret"));
    game.add(new Spider("spider", 3, 3, 0.618f, 30, 30));
    {
        NARSeed e = newDefault(3);
        NAR nar = new NAR(e);
        game.add(new Rover("r1", nar));
    }
    {
        NAR nar = new NAR(newDefault(1));
        // nar.param.outputVolume.set(0);
        game.add(new CarefulRover("r2", nar));
    /*if (cpanels) {
                SwingUtilities.invokeLater(() -> {
                    new NARSwing(nar, false);
                });
            }*/
    }
    game.run(fps);
}
Also used : Rover(nars.rover.robot.Rover) CarefulRover(nars.rover.robot.CarefulRover) CarefulRover(nars.rover.robot.CarefulRover) RoverWorld(nars.rover.RoverWorld) Sim(nars.rover.Sim) Spider(nars.rover.robot.Spider) NARSeed(nars.NARSeed) Turret(nars.rover.robot.Turret) NAR(nars.NAR) FoodSpawnWorld1(nars.rover.world.FoodSpawnWorld1)

Aggregations

NAR (nars.NAR)124 Test (org.junit.jupiter.api.Test)92 NARS (nars.NARS)23 Term (nars.term.Term)20 Truth (nars.truth.Truth)18 TestNAR (nars.test.TestNAR)16 BeliefTable (nars.table.BeliefTable)10 Disabled (org.junit.jupiter.api.Disabled)9 PrologCore (nars.op.prolog.PrologCore)8 Nullable (org.jetbrains.annotations.Nullable)8 Task (nars.Task)7 Concept (nars.concept.Concept)6 Param (nars.Param)5 Termed (nars.term.Termed)5 List (java.util.List)4 FasterList (jcog.list.FasterList)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 nars.$ (nars.$)3 ITask (nars.task.ITask)3 NALTest (nars.util.NALTest)3