diff --git a/test/test-ag1.js b/test/test-ag1.js new file mode 100644 index 0000000..7c250b8 --- /dev/null +++ b/test/test-ag1.js @@ -0,0 +1,37 @@ +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(); +