Search in sources :

Example 1 with RLBooster

use of nars.op.RLBooster in project narchy by automenta.

the class TrackXY method main.

public static void main(String[] args) {
    boolean nars = true;
    boolean rl = false;
    int dur = 1;
    NARS nb = new NARS().exe(new UniExec(64)).time(new CycleTime().dur(dur)).index(// new HijackConceptIndex(4 * 1024, 4)
    new CaffeineIndex(32 * 1024));
    NAR n = nb.get();
    n.termVolumeMax.set(20);
    // n.priDefault(BELIEF, 0.2f);
    // n.priDefault(GOAL, 0.5f);
    n.activationRate.set(0.2f);
    // n.forgetRate.set(0.9f);
    TrackXY t = new TrackXY(4, 4);
    n.on(t);
    int experimentTime = 8048;
    n.synch();
    if (rl) {
        new RLBooster(t, // HaiQ::new,
        HaiQae::new, // RandomAgent::new,
        1);
        t.curiosity.set(0);
    }
    if (nars) {
        // Param.DEBUG = true;
        // n.log();
        // for (String action : new String[]{"up", "down", "left", "right"}) {
        // //n.goal($.the(action), Tense.Present, 0f, 0.1f);
        // n.goal($.the(action), Tense.Present, 1f, 0.1f);
        // }
        Deriver d = new Deriver(Derivers.rules(// 1,
        1, 8, n, // "list.nal",
        "motivation.nal"), n);
        d.conceptsPerIteration.set(32);
        n.timeFocus.set(2);
        ConjClustering cjB = new ConjClustering(n, BELIEF, // (tt)->true,
        (tt) -> tt.isInput(), 4, 16);
        // ConjClustering cjG = new ConjClustering(n, GOAL,
        // (tt)->true,
        // //(tt) -> tt.isInput(),
        // 5, 16);
        // Implier ii = new Implier(t , 0, 1);
        // ArithmeticIntroduction ai = new ArithmeticIntroduction(4, n);
        window(new Gridding(new AutoSurface(d), new AutoSurface(cjB)), 400, 300);
        n.onTask(tt -> {
            if (tt instanceof DerivedTask && tt.isGoal()) {
                System.out.println(tt.proof());
            }
        });
    }
    // n.log();
    // n.startFPS(fps);
    // t.runFPS(fps);
    n.onCycle(t);
    final double[] rewardSum = { 0 };
    n.onCycle(() -> {
        rewardSum[0] += t.reward;
    });
    n.runLater(() -> {
        window(Vis.top(n), 800, 250);
        NAgentX.chart(t);
        window(new CameraSensorView(t.cam, n) {

            @Override
            protected void paint(GL2 gl, int dtMS) {
                super.paint(gl, dtMS);
                RectFloat2D at = cellRect(t.sx, t.sy, 0.5f, 0.5f);
                gl.glColor4f(1, 0, 0, 0.9f);
                Draw.rect(gl, at.move(x(), y(), 0.01f));
            }
        }.withControls(), 800, 800);
    });
    n.run(experimentTime);
// n.startFPS(10f);
// t.runFPS(10f);
// System.out.println(
// 
// n4(rewardSum[0] / n.time()) + " avg reward");
// System.exit(0);
}
Also used : HaiQae(jcog.learn.ql.HaiQae) RectFloat2D(jcog.tree.rtree.rect.RectFloat2D) RLBooster(nars.op.RLBooster) GL2(com.jogamp.opengl.GL2) DerivedTask(nars.task.DerivedTask) UniExec(nars.exe.UniExec) CaffeineIndex(nars.index.term.map.CaffeineIndex) CameraSensorView(nars.video.CameraSensorView) CycleTime(nars.time.CycleTime) Deriver(nars.derive.Deriver) Gridding(spacegraph.space2d.container.Gridding) ConjClustering(nars.op.stm.ConjClustering) AutoSurface(spacegraph.space2d.widget.meta.AutoSurface)

Aggregations

GL2 (com.jogamp.opengl.GL2)1 HaiQae (jcog.learn.ql.HaiQae)1 RectFloat2D (jcog.tree.rtree.rect.RectFloat2D)1 Deriver (nars.derive.Deriver)1 UniExec (nars.exe.UniExec)1 CaffeineIndex (nars.index.term.map.CaffeineIndex)1 RLBooster (nars.op.RLBooster)1 ConjClustering (nars.op.stm.ConjClustering)1 DerivedTask (nars.task.DerivedTask)1 CycleTime (nars.time.CycleTime)1 CameraSensorView (nars.video.CameraSensorView)1 Gridding (spacegraph.space2d.container.Gridding)1 AutoSurface (spacegraph.space2d.widget.meta.AutoSurface)1