jam/test/test-ag1.js

38 lines
677 B
JavaScript
Raw Normal View History

2024-08-27 00:15:26 +02:00
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();