Search in sources :

Example 51 with NAR

use of nars.NAR in project narchy by automenta.

the class NARAudio method main.

public static void main(String[] args) {
    NAR n = NARS.shell();
    new NARAudio(n).start(n);
}
Also used : NAR(nars.NAR)

Example 52 with NAR

use of nars.NAR in project narchy by automenta.

the class SoNAR method main.

public static void main(String[] args) throws LineUnavailableException, InterruptedException, Narsese.NarseseException {
    NAR n = new NARS().get();
    // n.log();
    n.input("a:b. :|: (--,b:c). c:d. d:e. (--,e:f). f:g. b:f. a:g?");
    n.startPeriodMS(16);
    SoNAR s = new SoNAR(n);
    SampleDirectory d = new SampleDirectory();
    d.samples("/home/me/wav/legoweltkord");
    s.listen(n.conceptualize($("a")), d::byHash);
    s.listen(n.conceptualize($("b")), d::byHash);
    s.listen(n.conceptualize($("c")), d::byHash);
    s.listen(n.conceptualize($("d")), d::byHash);
    s.listen(n.conceptualize($("e")), d::byHash);
    s.listen(n.conceptualize($("f")), d::byHash);
    s.listen(n.conceptualize($("g")), d::byHash);
    s.listen(n.conceptualize($("a:b")), d::byHash);
    s.listen(n.conceptualize($("b:c")), d::byHash);
    s.listen(n.conceptualize($("c:d")), d::byHash);
    s.listen(n.conceptualize($("d:e")), d::byHash);
    s.listen(n.conceptualize($("e:f")), d::byHash);
    s.listen(n.conceptualize($("f:g")), d::byHash);
    s.listen(n.conceptualize($("a:g")), d::byHash);
    try {
        s.audio.record("/tmp/test.raw");
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    s.join();
}
Also used : NARS(nars.NARS) Sound(spacegraph.audio.Sound) FileNotFoundException(java.io.FileNotFoundException) NAR(nars.NAR)

Example 53 with NAR

use of nars.NAR in project narchy by automenta.

the class SimpleConceptGraph1 method main.

public static void main(String[] args) {
    // Param.DEBUG = true;
    // Param.TRACE = true;
    NAR n = NARS.threadSafe();
    // new DeductiveChainTest(n, 8,  2048, inh);
    SimpleConceptGraph1 g = new SimpleConceptGraph1(n, /* TODO */
    128, 5);
// n.conceptActivation.set(0.2f);
// csvPriority(n, "/tmp/x.csv");
// Default n = O.of(new Default.DefaultTermIndex(512, new NARS.ExperimentalConceptBuilder()),
// new CycleTime(), new BufferedSynchronousExecutor(64, 0.5f)).the(Default.class);
// Default n = NARBuilder.newMultiThreadNAR(1, new RealTime.DSHalf(true).durSeconds(0.05f));
// n.nal(1);
// n.termVolumeMax.setValue(7f);
// n.DEFAULT_BELIEF_PRIORITY = 0.9f;
// n.DEFAULT_GOAL_PRIORITY = 0.9f;
// n.DEFAULT_QUESTION_PRIORITY = 0.01f;
// n.DEFAULT_QUEST_PRIORITY = 0.01f;
// n.inputAt(1, "c:a?");
// n.inputAt(2, "b:a.");
// n.inputAt(3, "c:b.");
// "(x:a ==> x:b).",
// "(x:b ==> x:c).",
// "(x:c ==> x:d).",
// "(x:d ==> x:e).",
// "(x:e ==> x:f)."
// "(x:f ==> x:g).",
// "(x:g ==> x:h)."
// for (int i = 0; i < 10; i++) {
// n.inputAt(i * 5 , i % 2 == 0 ? "x:c! :|:" : "--x:c! :|:");
// }
// n.log();
// n.loop(2f);
// for (int i = 1; i < 24; i++)
// n.inputAt(i*2,"(" + ((char)('a' + i)) + "). :|:");
// new DeductiveMeshTest(n, new int[]{3, 2}, 16384);
// n.onCycle(nn->{System.out.println(nn.time() + "\n" + n.exe.stats() + "\n\n");});
// n.services.printServices(System.out);
// n.run(600);
// n.log();
// n.input(
// "(a-->b).", "(b-->c)."
// );
// n.input(
// "(c-->d).","(d-->e).","(e-->a).",
// "(a<->x)!"
// );
// 
// n.run(1).input("x(set,3)!  :|:");
// n.run(1).input("x(set,3).  :|:");
// n.run(1).input("x(get,#x)! :|:");
// n.run(1).input("x(get,3).  :|:");
// n.run(1).input("$1.0 x(get,4)!");
// "{a,b}.", "{b,c}.","{c,d}."
// ,"{d,e}.","{e,a}.", "(a,b,c,b)! :|:"
// ,"(a &&+1 b). :|:"
// "$.50 at(SELF,{t001}). :|: %1.0;.90%", "$.70 (at(SELF,{t001}) &&+5 open({t001}))! %1.0;.90%" // //goal_ded_2
// new DeductiveChainTest(n, 10, 9999991, (x, y) -> $.p($.the(x), $.the(y)));
// n.linkFeedbackRate.setValue(0.05f);
// Param.DEBUG = true;
// n
// //.log()
// //.logSummaryGT(System.out, 0.05f)
// .input(
// //                        "((parent($X,$Y) && parent($Y,$Z)) <=> grandparent($X,$Z)).",
// //                        "parent(c, p).",
// //                        "parent(p, g).",
// //                        "grandparent(p, #g)?"
// "x:(a,(b,c))."
// //                        "$0.9;0.9;0.9$ (a,(b,(c,(d,e))))."
// //
// );
// //.run(800);
// 
}
Also used : NAR(nars.NAR)

Example 54 with NAR

use of nars.NAR in project narchy by automenta.

the class IRCAgent method main.

public static void main(String[] args) {
    // Param.DEBUG = true;
    // NARS.realtime().get();
    @NotNull NAR n = NARchy.ui();
    // newRealtimeNAR(1024, 25, 2);
    n.termVolumeMax.set(20);
    // Control c = n.getControl();
    // n.setControl(new ChainedControl(c) {
    // //            @Override
    // //            public void activate(Termed term, float priToAdd) {
    // //
    // //                synchronized(this) {
    // //                    System.out.print(term + " " + priToAdd + "\t===");
    // //                    super.activate(term, priToAdd);
    // //                    System.out.println(pri(term));
    // //                }
    // //            }
    // });
    IRCAgent bot = new IRCAgent(n, "experiment1", "irc.freenode.net", // "#123xyz"
    "#netention");
    n.onOpN("trace", (arg, nn) -> {
        if (arg.subs() > 0) {
            switch(arg.sub(0).toString()) {
                case "on":
                    bot.setTrace(true);
                    break;
                case "off":
                    bot.setTrace(false);
                    bot.out.clear();
                    break;
            }
        }
    });
    /*
        n.on("readToUs", (Command) (a, t, nn) -> {
            if (t.length > 0) {
                String url = $.unquote(t[0]);
                if (canReadURL(url)) {
                    try {

                        Term[] targets;
                        if (t.length > 1 && t[1] instanceof Compound) {
                            targets = ((Compound)t[1]).terms();
                        } else {
                            targets = null;
                        }

                        Collection<String> lines = IOUtil.readLines(new URL(url).openStream());

                        new RateIterator<String>(lines.iterator(), 2)
                                .threadEachRemaining(l -> {

                                    bot.hear(l, nn.self().toString());

                                    if (targets == null) {
                                        bot.broadcast(l);
                                    } else {
                                        for (Term u : targets)
                                            bot.send($.unquote(u), l);
                                    }

                                }).start();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        });
        */
    /*

        try {
            new RateIterator<Task>(
                NQuadsRDF.stream(n,
                    new File("/home/me/Downloads/nquad")), 500)
                        .threadEachRemaining(n::inputLater).start();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        */
    // new NARWeb(n, 8080);
    n.startFPS(10f);
    try {
        bot.start();
    } catch (IOException | IrcException e) {
        e.printStackTrace();
    }
// nar.run(1);
}
Also used : IOException(java.io.IOException) NotNull(org.jetbrains.annotations.NotNull) IrcException(org.pircbotx.exception.IrcException) NAR(nars.NAR)

Example 55 with NAR

use of nars.NAR in project narchy by automenta.

the class PrologCoreTest method testPrologCoreDerivedTransitive.

@Test
public void testPrologCoreDerivedTransitive() throws Narsese.NarseseException {
    NAR n = NARS.tmp();
    PrologCore p = new PrologCore(n);
    n.input("a:b.");
    n.input("b:c.");
    n.run(1);
    n.input("a:c?");
    // expect true
    n.run(1);
    n.input("a:d?");
    // expect false
    n.run(1);
}
Also used : PrologCore(nars.op.prolog.PrologCore) NAR(nars.NAR) Test(org.junit.jupiter.api.Test)

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