jam/test/test-ag1.js

38 lines
677 B
JavaScript

function ac(options) {
this.options=options;
this.sensor=null;
this.act = {
start: function () {
log('Starting .. '+this.options.msg)
},
percept: function () {
rd.try(0,['SENSOR',_],function (t) {
if (t) this.sensor=t[1];
})
},
action : function () {
log(this.sensor);
},
stop: function () {
log('Terminating ..')
kill()
}
}
this.trans = {
start:"percept",
percept: function () {
if (this.sensor!=null) return "action";
else return "stop";
},
action:"stop"
}
this.next="start";
}
out(['SENSOR',1000])
var ag1 = create(ac,{msg:'with pace'},2);
start();